package com.sportizz.sport;

import static com.sportizz.sport.CommonUtilities.DISPLAY_MESSAGE_ACTION;
import static com.sportizz.sport.CommonUtilities.SENDER_ID;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.R.color;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.location.Address;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Events;
import android.provider.CalendarContract.Instances;
import android.provider.CalendarContract.Reminders;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AbsListView.MultiChoiceModeListener;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
import android.widget.ToggleButton;

import com.sportizz.model.JustifiedTextView;
import com.sportizz.model.Player;
import com.sportizz.model.PlayerData;
import com.sportizz.model.new_ifollow_player;
import com.sportizz.model.player_info;
import com.sportizz.model.player_search;
import com.sportizz.model.sports;
import com.sportizz.sport.MainActivity.PlayerAdapter;
import com.sportizz.sport.R;
import com.sportizz.sport.row.Br_custom_player_list;
import com.sportizz.sport.row.Br_custom_team_list;
import com.sportizz.sport.row.ChampRow;
import com.sportizz.sport.row.Custom_set_row;
import com.sportizz.sport.row.PlayerRow;
import com.sportizz.sport.row.Row;
import com.sportizz.sport.row.Rowtype;
import com.sportizz.sport.row.TeamRow;
import com.sportizz.sport.row.new_Br_custom_player_list;
import com.sportizz.sport.row.new_Br_custom_team_list;
import com.sportizz.sport.row.old_ChampRow;
import com.google.ads.*;
import com.google.android.gcm.GCMRegistrar;

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("SimpleDateFormat")
public class MainActivity extends Activity {

	public ListView lv;

	String country_name;
	Address obj;
	Activity act;
	public ArrayList<String> sport_cs_adp = null, sport_team_adp = null,
			teamplayer_adp = null, sport_adp = null, sport_player_adp = null,
			sport_player_adp1 = null;
	public static InterstitialAd interstitial;

	public ProgressDialog pd = null;
	public String upcominValue = null;
	public String cs_code_selected = null, sport_name_grid = null;
	public String sport_code = null, team_sports = null;

	public String team_code_selected = null, Champion_name = null,
			team_Name = null;

	public static List<new_ifollow_player> new_follow_match;
	public static List<new_ifollow_player> new_upcoming_match;

	double lat, lon;
	public static int playerAdaptersize = 0;

	public String country_code;

	ProgressDialog pDialog;
	private DatabaseAdapter dataAdapter;

	private AutoCompleteTextView search_text;
	private LinearLayout ll, btn_rl;

	private RelativeLayout main, list_layout;

	private Button i_follow, all_sport, setting, upcoming, browser;
	private TextView txt_r_follow, txt_upcoming, unlimited_name,
			txt_check_calendar, calendar_name, upcoming_name;

	// public static ToggleButton check_cal;
	// public static Button txt_info, btn_info, nexthr_info, plus,
	// minus,br_back_first,br_back_sec;

	public static TextView ch_page_sportName, ch_page_sportName2,
			br_champ_name, br2_champ_name;
	private PopupWindow pwindo;

	PlayerAdapter player_adp = null;
	TextView empty, empty_not;
	public static Context context;
	LayoutInflater inflater;
	ViewGroup header1;

	public static WebView webView1;

	DbHandler handler;

	AsyncTask<Void, Void, Void> mRegisterTask;

	AlertDialogManager alert = new AlertDialogManager();

	ConnectionDetector cd;

	public static String email, champ_name_temp = null;

	public static String team_name_temp = null, team_code_temp = null;

	public static boolean tablet, search_boolean = false;
	public static String device_id;
	public static String name = null;
	public static HashMap<String, String> json = null;
	public static HashMap<String, String> player_name;

	public String follow_pl = null;

	// public static HashMap<String, String> search_list = null;
	public static ArrayList<Map<String, String>> Serachresult = null;

	public static HashMap<String, String> cs_code;

	public static ArrayList<String> result_main;
	public static String first_time = "true";
	public static String pur_status = null;

	public static AdView adView;
	public static String[] temp_sport_team;

	public static SharedPreferences preferences_purchase = null;

	public static SharedPreferences preferences13 = null, Back_action = null;

	public static List<String> champ = new ArrayList<String>();
	public static List<String> player = new ArrayList<String>();;
	public static List<String> playerAll = new ArrayList<String>();;

	public static Button btn_news, btn_up, btn_teams, btn_tweets, button_back;
	public String br_sport_name;

	List<player_info> playerrowItems;

	public static Button option_popup;
	public static TextView actionbar_title;
	public static ImageView app_logo;
	public static boolean optionpress = true;
	boolean start = false;

	public static ProgressBar action_progress;
	private MenuItem refreshMenuItem;
	private ActionBar actionBar;

	public static ImageView search_view;

	public static PopupWindow popupWindow;

	public StartActivity sa;
	Typeface sport_font;

	@SuppressLint("NewApi")
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		final Window win = getWindow();
		win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
				| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
		win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
				| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

		// startActivity(new Intent(this,First_sport_follow.class));
		getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

		LayoutInflater inflater = (LayoutInflater) getActionBar()
				.getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE);
		View customActionBarView = inflater.inflate(R.layout.action_bar, null);

		actionBar = getActionBar();
		actionBar.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.actionbar_bg));
		actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
				| ActionBar.DISPLAY_SHOW_TITLE);
		actionBar.setCustomView(customActionBarView,
				new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
						ViewGroup.LayoutParams.MATCH_PARENT));

		win.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
				WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

		// ...but notify us that it happened.
		win.setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
				WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);

		setContentView(R.layout.activity_main);

		btn_news = (Button) findViewById(R.id.btn_news);
		btn_up = (Button) findViewById(R.id.btn_up);
		btn_teams = (Button) findViewById(R.id.btn_teams);
		btn_tweets = (Button) findViewById(R.id.btn_tweets);
		button_back = (Button) findViewById(R.id.button_back);

		sport_font = Typeface.createFromAsset(getAssets(), "hel57.ttf");

		btn_news.setTypeface(sport_font);
		btn_up.setTypeface(sport_font);
		btn_teams.setTypeface(sport_font);
		btn_tweets.setTypeface(sport_font);
		button_back.setTypeface(sport_font);

		app_logo = (ImageView) customActionBarView.findViewById(R.id.app_logo);
		option_popup = (Button) customActionBarView
				.findViewById(R.id.btn_popup);
		actionbar_title = (TextView) customActionBarView
				.findViewById(R.id.actionBar_title);
		action_progress = (ProgressBar) customActionBarView
				.findViewById(R.id.progressBar_action);
		search_view = (ImageView) customActionBarView
				.findViewById(R.id.search_imageview);

		search_text = (AutoCompleteTextView) customActionBarView
				.findViewById(R.id.search_name_text);

		option_popup.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				search_view.setVisibility(View.VISIBLE);
				search_text.setVisibility(View.GONE);
				action_progress.setVisibility(View.GONE);
				app_logo.setVisibility(View.VISIBLE);

				Main_menu();

			}
		});

		int currentapiVersion = android.os.Build.VERSION.SDK_INT;

		Log.v("suraj", "currentapiVersion = " + currentapiVersion);
		/***********/
		context = this;
		act = (Activity) context;

		result_main = new ArrayList<String>();

		webView1 = (WebView) findViewById(R.id.webView1);

		list_layout = (RelativeLayout) findViewById(R.id.list_layout);

		lv = (ListView) findViewById(R.id.listView1);

		preferences_purchase = context.getSharedPreferences("purchase_status",
				Context.MODE_PRIVATE);

		preferences13 = context.getSharedPreferences("check_addcal",
				Context.MODE_PRIVATE);
		boolean check_addcal = preferences13.getBoolean("check_addcal", false);

		Back_action = context.getSharedPreferences("Back_action",
				Context.MODE_PRIVATE);

		Back_action.getString("Back_action", null);

		Log.i("suraj", "check_addcal = " + check_addcal);

		interstitial = new InterstitialAd(this, "a1524671e72ea0a");

		AdRequest adRequest1 = new AdRequest();
		adRequest1.addTestDevice(AdRequest.TEST_EMULATOR);
		interstitial.loadAd(adRequest1);

		if (interstitial.isReady()) {
			interstitial.show();
		} else {
			Log.d("suraj_", "Interstitial ad was not ready to be shown.");
		}

		String first_time_str = null;

		first_time_str = StartActivity.preferences
				.getString("first_time", null);

		Log.e("suraj", "First Time =" + first_time_str);

		// Log.e("suraj",
		// "Image URL =" + StartActivity.get_img_location.contains("Asia"));

		dataAdapter = new DatabaseAdapter(this);
		dataAdapter.open();

		Cursor sportfollow = dataAdapter.getsportfollow();
		sportfollow.moveToFirst();

		Log.d("suraj_", "sportfollow = " + sportfollow.getCount());
		if (sportfollow.getCount() > 0) {
			do {
				Log.d("suraj_",
						"sportfollow = "
								+ sportfollow.getString(sportfollow
										.getColumnIndexOrThrow("player_id")));
			} while (sportfollow.moveToNext());
		}
		dataAdapter.close();

		dataAdapter.open();

		handler = new DbHandler(getBaseContext());
		context = this;

		ll = (LinearLayout) findViewById(R.id.linearLayout1);

		btn_rl = (LinearLayout) findViewById(R.id.linearLayout2);

		empty = (TextView) findViewById(R.id.empty_text);
		empty_not = (TextView) findViewById(R.id.empty_text_Not);

		main = (RelativeLayout) findViewById(R.id.main);

		empty.setTypeface(sport_font);

		adView = (AdView) findViewById(R.id.adView);

		pur_status = preferences_purchase.getString("purchase_status", null);
		Log.d("suraj", "pur_status = " + pur_status);

		final int pur_foll = StartActivity.limited_follow.getInt("max_follow",
				3);
		Log.d("suraj", "pur_foll = " + pur_foll);

		Typeface font = Typeface
				.createFromAsset(getAssets(), "Hel67medium.ttf");

		all_sport = (Button) findViewById(R.id.new_tab_live);
		i_follow = (Button) findViewById(R.id.I_Follow);
		upcoming = (Button) findViewById(R.id.upcoming);

		all_sport.setTypeface(font);
		i_follow.setTypeface(font);
		upcoming.setTypeface(font);

		lv.setOnTouchListener(null);
		lv.setOnScrollListener(null);

		Intent intent = getIntent();
		country_code = intent.getStringExtra("country_code");
		email = intent.getStringExtra("email");
		device_id = intent.getStringExtra("device_id");

		Log.d("suraj", "country_code= " + country_code + "; "
				+ StartActivity.what_new + "; " + device_id);

		if (!StartActivity.what_new.equals("")
				|| StartActivity.what_new != null) {
			String[] btn_live = StartActivity.what_new.split(":");

			all_sport.setVisibility(View.VISIBLE);
			all_sport.setText(btn_live[0]);
		} else {
			all_sport.setVisibility(View.GONE);
		}

		lv.setAdapter(null);
		if (first_time_str == null) {
			//
			// dataAdapter.close();
			// dataAdapter.open();
			// String cal_value = dataAdapter.getcalValue();
			//
			//
			// if (cal_value.equals("N")) {
			// AlertDialog.Builder builder = new AlertDialog.Builder(this);
			// builder.setMessage(
			// "Sportizza wants to request access to Calendar to schedule your favourite events.")
			// .setCancelable(false);
			// builder.setTitle("Access Calendar")
			// .setPositiveButton("Yes",
			// new DialogInterface.OnClickListener() {
			// public void onClick(DialogInterface dialog,
			// int id) {
			//
			// // check_cal.setChecked(true);
			// dataAdapter.close();
			// dataAdapter.open();
			//
			// dataAdapter.updatecalValue("Y", "N");
			//
			// dataAdapter.close();
			//
			// SharedPreferences.Editor editor13 = preferences13
			// .edit();
			// editor13.putBoolean("check_addcal",
			// true);
			// editor13.commit();
			//
			// Log.v("suraj",
			// "BOOLEAN = "
			// + preferences13
			// .getBoolean(
			// "check_addcal",
			// false));
			// dialog.dismiss();
			// }
			//
			// })
			// .setNegativeButton("No",
			// new DialogInterface.OnClickListener() {
			// public void onClick(DialogInterface dialog,
			// int id) {
			//
			//
			// dataAdapter.close();
			//
			// SharedPreferences.Editor editor13 = preferences13
			// .edit();
			// editor13.putBoolean("check_addcal",
			// false);
			// editor13.commit();
			//
			// dialog.dismiss();
			//
			// }
			// });
			// AlertDialog alert1 = builder.create();
			// alert1.show();
			// }

			GCMRegistrar.unregister(this);

			cd = new ConnectionDetector(getApplicationContext());

			// Check if Internet present
			if (!cd.isConnectingToInternet()) {
				// Internet Connection is not present
				alert.showAlertDialog(MainActivity.this,
						"Internet Connection Error",
						"Please connect to working Internet connection", false);
				// stop executing code by return
				return;
			}

			Log.d("suraj", "Mail = " + email + " ID =" + device_id);

			GCMRegistrar.checkDevice(this);

			GCMRegistrar.checkManifest(this);

			registerReceiver(mHandleMessageReceiver, new IntentFilter(
					DISPLAY_MESSAGE_ACTION));

			// Get GCM registration id
			final String regId = GCMRegistrar.getRegistrationId(this);

			Log.v("suraj", "REg ID=" + regId);

			// Check if regid already presents
			if (regId.equals("")) {
				// Registration is not present, register now with GCM
				GCMRegistrar.register(this, SENDER_ID);
				SharedPreferences.Editor editor = StartActivity.preferences
						.edit();
				editor.putString("first_time", "false");
				editor.commit();
			} else {
				// Device is already registered on GCM
				if (GCMRegistrar.isRegisteredOnServer(this)) {
					// Skips registration.
					SharedPreferences.Editor editor = StartActivity.preferences
							.edit();
					editor.putString("first_time", "false");
					editor.commit();

					Log.v("suraj", "Already registered");
					Toast.makeText(getApplicationContext(),
							"Already registered with GCM", Toast.LENGTH_LONG)
							.show();
				} else {
					final Context context = this;
					mRegisterTask = new AsyncTask<Void, Void, Void>() {

						@Override
						protected Void doInBackground(Void... params) {
							// Register on our server
							// On server creates a new user
							Log.d("suraj", "in BAck");
							ServerUtilities.register(context, name, email,
									device_id, regId);
							return null;
						}

						@Override
						protected void onPostExecute(Void result) {
							mRegisterTask = null;
						}

					};
					mRegisterTask.execute(null, null, null);
					SharedPreferences.Editor editor = StartActivity.preferences
							.edit();
					editor.putString("first_time", "false");
					editor.commit();
				}
			}
		}
		// main_work();

		String updateversion = Utils.readJsonFeed(
				"http://www.sportizza.com/interface/android_ver.php", this);

		int update_version = 0;
		int currentversion = 0;
		if (updateversion.equals("null")) {

		} else {
			update_version = Integer.parseInt(updateversion);
		}

		try {
			Log.d("suraj",
					"update_version= "
							+ updateversion
							+ "currentversion = "
							+ getPackageManager().getPackageInfo(
									getPackageName(), 0).versionCode);
			currentversion = getPackageManager().getPackageInfo(
					getPackageName(), 0).versionCode;

		} catch (NameNotFoundException e1) {
			e1.printStackTrace();
		}

		if (update_version > currentversion) {
			try {
				AlertDialog.Builder builder = new AlertDialog.Builder(this);
				builder.setMessage(
						"Please upgrade Sportizza to enjoy the latest features \n")
						.setCancelable(false);
				builder.setTitle("Update Notice")
						.setPositiveButton("Yes",
								new DialogInterface.OnClickListener() {
									public void onClick(DialogInterface dialog,
											int id) {

										String marketPage = "market://details?id="
												+ getPackageName();
										Intent intent = new Intent(
												Intent.ACTION_VIEW);
										intent.setData(Uri.parse(marketPage));
										startActivity(intent);

										dialog.dismiss();
									}

								})
						.setNegativeButton("No",
								new DialogInterface.OnClickListener() {
									public void onClick(DialogInterface dialog,
											int id) {

										dialog.dismiss();

									}
								});
				AlertDialog alert1 = builder.create();
				alert1.show();
			} catch (Exception e) {
			}
		}

		main.setOnTouchListener(new View.OnTouchListener() {

			@Override
			public boolean onTouch(View arg0, MotionEvent arg1) {
				if (search_text.isFocused()) {

					search_text.clearFocus();

					search_view.setVisibility(View.VISIBLE);
					search_text.setVisibility(View.GONE);
					action_progress.setVisibility(View.GONE);
					app_logo.setVisibility(View.VISIBLE);

					MainActivity.this
							.getWindow()
							.setSoftInputMode(
									WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

					hideKeyboard();
				}// //
				return false;
			}
		});

		lv.setOnScrollListener(new OnScrollListener() {

			@Override
			public void onScrollStateChanged(AbsListView arg0, int arg1) {

			};

			@Override
			public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
				if (search_text.isFocused()) {

					search_text.clearFocus();

					search_view.setVisibility(View.VISIBLE);
					search_text.setVisibility(View.GONE);
					action_progress.setVisibility(View.GONE);
					app_logo.setVisibility(View.VISIBLE);
					MainActivity.this
							.getWindow()
							.setSoftInputMode(
									WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

				}
			}
		});

		search_view.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				// search_text.requestFocus();

				search_text.requestFocus();
				search_view.setVisibility(View.GONE);
				search_text.setVisibility(View.VISIBLE);
				action_progress.setVisibility(View.GONE);
				app_logo.setVisibility(View.GONE);

				search_boolean = true;

			}
		});

		final PlacesAutoCompleteAdapter placeadapter = new PlacesAutoCompleteAdapter(
				MainActivity.this, R.layout.list_item);
		search_text.setAdapter(placeadapter);
		try {
			placeadapter.notifyDataSetChanged();
		} catch (Exception e) {
		}
		search_text.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence arg0, int arg1, int arg2,
					int arg3) {
				try {
					placeadapter.notifyDataSetChanged();
				} catch (Exception e) {
				}
			}

			@Override
			public void beforeTextChanged(CharSequence arg0, int arg1,
					int arg2, int arg3) {

			}

			@Override
			public void afterTextChanged(Editable arg0) {
				try {
					placeadapter.notifyDataSetChanged();
				} catch (Exception e) {
				}
			}
		});
		try {
			placeadapter.notifyDataSetChanged();
		} catch (Exception e) {
		}

		search_text.setOnEditorActionListener(new OnEditorActionListener() {

			@Override
			public boolean onEditorAction(TextView arg0, int actionId,
					KeyEvent arg2) {

				if (actionId == EditorInfo.IME_ACTION_SEARCH) {
					// final PlacesAutoCompleteAdapter placeadapter = new
					// PlacesAutoCompleteAdapter(
					// MainActivity.this, R.layout.list_item);
					//
					// search_text.setAdapter(placeadapter);
					try {
						placeadapter.notifyDataSetChanged();
					} catch (Exception e) {
					}
					hideKeyboard();

					// final ArrayList<String> search_list = new
					// ArrayList<String>();
					// final List<player_search> pl_search=new
					// ArrayList<player_search>();
					//
					// result_main = new ArrayList<String>();
					//
					//
					// final New_PlacesAutoAdapter new_placeadapter =new
					// New_PlacesAutoAdapter(context, search_list);
					// search_text.setAdapter(new_placeadapter);
					//
					//
					// AsyncTask<Void, Void, ArrayList<String>> search_wait =
					// new AsyncTask<Void, Void, ArrayList<String>>()
					// {
					//
					// @Override
					// protected void onPostExecute(ArrayList<String> result) {
					// // TODO Auto-generated method stub
					// super.onPostExecute(result);
					//
					// result_main = result;
					// new_placeadapter.notifyDataSetChanged();
					//
					// pd.dismiss();
					// search_text.requestFocus();
					// hideKeyboard();
					// }
					//
					// @Override
					// protected void onPreExecute() {
					//
					// pd = ProgressDialog.show(context, "", "Searching...",
					// true);
					// super.onPreExecute();
					// }
					//
					// @Override
					// protected ArrayList<String> doInBackground(Void...
					// params) {
					//
					// String sch_txt =
					// search_text.getText().toString().replace(" ", "%20");
					//
					// String search_responce =
					// Utils.readJsonFeed("http://sportizza.com/interface/autocomplete.php?term="+sch_txt+"",
					// MainActivity.this);
					//
					// Log.d("suraj","Search Resuylt = "+search_responce);
					// try {
					// JSONArray predsJsonArray = new
					// JSONArray(search_responce);
					//
					// pl_search.clear();
					//
					// for (int i = 0; i < predsJsonArray.length(); i++) {
					//
					//
					// pl_search.add(new player_search(predsJsonArray
					// .getJSONObject(i).getString("ss_player_name"),
					// predsJsonArray.getJSONObject(i).getString(
					// "ss_player_code"),
					// predsJsonArray.getJSONObject(i).getString(
					// "ss_sport"), predsJsonArray
					// .getJSONObject(i).getString(
					// "ss_is_team")));
					//
					// search_list.add(predsJsonArray.getJSONObject(i).getString(
					// "ss_player_name")
					// + ":"
					// + predsJsonArray.getJSONObject(i).getString(
					// "ss_player_code")
					// + ":"
					// + predsJsonArray.getJSONObject(i).getString(
					// "ss_sport")
					// + ":"
					// + predsJsonArray.getJSONObject(i).getString(
					// "ss_is_team"));
					//
					// }
					// } catch (JSONException e) {
					// Log.e("suraj", "Cannot process JSON results", e);
					// }
					//
					//
					// return search_list;
					// }
					//
					// };
					// search_wait.execute();

					return true;
				}
				// placeadapter.notifyDataSetChanged();

				return false;
			}

		});

		search_text.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				adView.setVisibility(View.GONE);

			}
		});

		lv.setAdapter(null);
		String champ_list = "";
		String champ_sport = "";
		String player_list = "";
		String player_sport = "";
		final String sport_list = "";
		final ArrayList<String> pl_list = new ArrayList<String>();
		final ArrayList<String> cp_list = new ArrayList<String>();

		Cursor get_all_follow = dataAdapter.getfollowerlist();
		startManagingCursor(get_all_follow);

		Cursor get_champ_follow = dataAdapter.getchamplist();
		startManagingCursor(get_champ_follow);

		Log.v("suraj", "get_all_follow " + get_all_follow.getCount());

		if (get_champ_follow != null && get_champ_follow.getCount() > 0) {

			get_champ_follow.moveToFirst();

			do {
				champ_list = get_champ_follow.getString(get_champ_follow
						.getColumnIndex("player_id")) + "," + champ_list;

				champ_sport = get_champ_follow.getString(get_champ_follow
						.getColumnIndex("sport_code")) + "," + champ_sport;

				playerAll.add(get_champ_follow.getString(get_champ_follow
						.getColumnIndex("player_id")));
				cp_list.add(get_champ_follow.getString(get_champ_follow
						.getColumnIndex("player_id")));

			} while (get_champ_follow.moveToNext());

			champ_list = champ_list.substring(0, champ_list.length() - 1);

			champ_sport = champ_sport.substring(0, champ_sport.length() - 1);

			Log.w("suraj", "champ= " + champ_list);

		} else {
			Log.w("suraj", "champ Follow Null");
			champ_list = "-1";
			champ_sport = "";
		}

		if (get_all_follow != null && get_all_follow.getCount() > 0) {
			// int cursor_count=0;

			get_all_follow.moveToFirst();

			do {
				player_list = get_all_follow.getString(get_all_follow
						.getColumnIndex("player_id")) + "," + player_list;

				player_sport = get_all_follow.getString(get_all_follow
						.getColumnIndex("sport_code")) + "," + player_sport;

				playerAll.add(get_all_follow.getString(get_all_follow
						.getColumnIndex("player_id")));

				pl_list.add(get_all_follow.getString(get_all_follow
						.getColumnIndex("player_id")));

			} while (get_all_follow.moveToNext());

			player_list = player_list.substring(0, player_list.length() - 1);

			player_sport = player_sport.substring(0, player_sport.length() - 1);

			Log.w("suraj", "player_list= " + player_list);

		} else {
			Log.w("suraj", "player/team Follow Null");
			player_list = "-1";
			player_sport = "";
		}

		final Cursor get_sport_follow = dataAdapter.getsportfollow();
		startManagingCursor(get_sport_follow);

		get_all_follow.close();
		get_champ_follow.close();

		// player_list ="2049";
		// pl_list.add(player_list);

		final String champ_list_final = champ_list;
		final String player_list_final = player_list;
		final String sport_list_final = sport_list;
		final String champ_sport_final = champ_sport;
		final String player_sport_final = player_sport;

		String pre_ollow = StartActivity.preferences_i_fo.getString(
				"pre_ollow", "");

		if (champ_list.equals("-1") && player_list.equals("-1")) {

			if (pre_ollow.equals("second")) {

				if (get_sport_follow != null && get_sport_follow.getCount() > 0) {
					// int cursor_count=0;
					new_follow_match = new ArrayList<new_ifollow_player>();

					final new_Player_adapter pladpt = new new_Player_adapter(
							MainActivity.this, new_follow_match,
							champ_list_final, champ_sport_final,
							player_list_final, player_sport_final);
					lv.setAdapter(pladpt);
					// pladpt.notifyDataSetChanged();

					AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

						@Override
						protected void onPostExecute(Void result) {
							// TODO Auto-generated method stub
							super.onPostExecute(result);
							pladpt.notifyDataSetChanged();
							action_progress.setVisibility(View.GONE);

						}

						@Override
						protected void onPreExecute() {
							action_progress.setVisibility(View.VISIBLE);
							super.onPreExecute();
						}

						@Override
						protected Void doInBackground(Void... params) {

							runOnUiThread(new Runnable() {

								@Override
								public void run() {

									// h.sendEmptyMessage(0);
									get_sport_follow.moveToFirst();
									String sport_lt = "";
									String sport = "";
									do {
										sport_lt = get_sport_follow
												.getString(get_sport_follow
														.getColumnIndex("player_id"));

										sport = get_sport_follow
												.getString(get_sport_follow
														.getColumnIndex("sport"));

										new_follow_match
												.add(new new_ifollow_player(
														null, null, null,
														sport_lt + ":" + sport,
														0));

									} while (get_sport_follow.moveToNext());

									// sport_list = sport_list.substring(0,
									// sport_list.length() - 1);

									// Log.w("suraj", "sport_list= " +
									// sport_list);

									Log.d("suraj", "vVideo i_follow = "
											+ new_follow_match.size());

									upcoming.setBackgroundDrawable(getResources()
											.getDrawable(R.drawable.tab_button));
									upcoming.setCompoundDrawablesWithIntrinsicBounds(
											0, 0, R.drawable.arrow_yellow, 0);
									upcoming.setTextColor(Color
											.parseColor("#FFCC11"));

									i_follow.setBackgroundDrawable(getResources()
											.getDrawable(R.drawable.tab_button1));
									i_follow.setCompoundDrawablesWithIntrinsicBounds(
											0, 0, R.drawable.arrow_black_r, 0);
									i_follow.setTextColor(Color.BLACK);

									all_sport
											.setBackgroundDrawable(getResources()
													.getDrawable(
															R.drawable.tab_button));
									all_sport
											.setCompoundDrawablesWithIntrinsicBounds(
													0, 0,
													R.drawable.arrow_yellow, 0);
									all_sport.setTextColor(Color
											.parseColor("#FFCC11"));

								}
							});

							return null;
						}
					};
					wait.execute();

				}
			}

			if (!pre_ollow.equals("second")) {

				SharedPreferences.Editor editor = StartActivity.preferences_i_fo
						.edit();
				editor.putString("pre_ollow", "second");
				editor.commit();

				upcoming();

				upcoming.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.tab_button1));
				upcoming.setCompoundDrawablesWithIntrinsicBounds(0, 0,
						R.drawable.arrow_black_r, 0);
				upcoming.setTextColor(Color.BLACK);

				i_follow.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.tab_button));
				i_follow.setCompoundDrawablesWithIntrinsicBounds(0, 0,
						R.drawable.arrow_yellow, 0);
				i_follow.setTextColor(Color.parseColor("#FFCC11"));

				all_sport.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.tab_button));
				all_sport.setCompoundDrawablesWithIntrinsicBounds(0, 0,
						R.drawable.arrow_yellow, 0);
				all_sport.setTextColor(Color.parseColor("#FFCC11"));

			}

		} else {

			// action_progress.setVisibility(View.VISIBLE);
			Log.w("suraj", "Enter else part first follow");

			new_follow_match = new ArrayList<new_ifollow_player>();

			final new_Player_adapter pladpt = new new_Player_adapter(
					MainActivity.this, new_follow_match, champ_list_final,
					champ_sport_final, player_list_final, player_sport_final);
			lv.setAdapter(pladpt);
			// pladpt.notifyDataSetChanged();

			AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

				@Override
				protected void onPostExecute(Void result) {
					// TODO Auto-generated method stub
					super.onPostExecute(result);
					pladpt.notifyDataSetChanged();
					action_progress.setVisibility(View.GONE);
				}

				@Override
				protected void onPreExecute() {
					action_progress.setVisibility(View.VISIBLE);
					super.onPreExecute();
				}

				@Override
				protected Void doInBackground(Void... params) {

					new Thread(new Runnable() {
						@Override
						public void run() {
							// Log.d("suraj", "champ_list not null main");

							runOnUiThread(new Runnable() {

								@Override
								public void run() {

									String i_follow_data = null;
									String i_follow_champ_data = null, new_champ = null, new_game = null, new_date = null;
									String ichamp_name_temp = null;

									String i_fol_url = "http://www.sportizza.com/interface/ios_all_follow_new.php?iso_cd="
											+ country_code
											+ "&follow="
											+ player_list_final
											+ "&follow_cs="
											+ champ_list_final
											+ "&follow_sport=-1";
									//
									Log.w("suraj", "pl_lis == " + pl_list);

									Log.d("suraj",
											"http://www.sportizza.com/interface/ios_all_follow_new.php?iso_cd="
													+ country_code + "&follow="
													+ player_list_final
													+ "&follow_cs="
													+ champ_list_final
													+ "&follow_sport=-1");
									try {
										String Json_result = Utils
												.readJsonFeed(i_fol_url,
														MainActivity.this);

										JSONArray array_ifollow_new = new JSONArray(
												Json_result);

										int json_len = array_ifollow_new
												.length();

										ArrayList<JSONObject> champ_jsonobject = new ArrayList<JSONObject>();

										ArrayList<JSONObject> player_team_jsonobject = new ArrayList<JSONObject>();

										for (int i = 0; i < json_len; i++) {
											JSONObject JsonObject_ifollow_new = array_ifollow_new
													.getJSONObject(i);

											String team_sport_ifollow_new = JsonObject_ifollow_new
													.getString("ss_team_sport");

											if (team_sport_ifollow_new
													.equals("A")) {
												champ_jsonobject
														.add(JsonObject_ifollow_new);
											} else {
												player_team_jsonobject
														.add(JsonObject_ifollow_new);
											}

										}

										Log.e("suraj",
												" Array Json Champ size ="
														+ champ_jsonobject
																.size());
										Log.w("suraj",
												" Array Json Player size ="
														+ player_team_jsonobject
																.size());

										// //////////player_team /////////////

										int count = 0;
										int chmp_count = 0;

										ArrayList<String> video_list = new ArrayList<String>();

										for (int b = 0; b < player_team_jsonobject
												.size(); b++) {

											JSONObject player_team_obj = player_team_jsonobject
													.get(b);

											String cs_code_new = player_team_obj
													.getString("ss_cs_code");

											String cs_name_new = player_team_obj
													.getString("ss_cs_name")
													.toUpperCase();

											String sport_name_new = player_team_obj
													.getString("ss_sport");

											String player_code1_new = player_team_obj
													.getString("ss_player_code1");
											String player_code2_new = player_team_obj
													.getString("ss_player_code2");
											String player_code3_new = player_team_obj
													.getString("ss_player_code3");
											String player_code4_new = player_team_obj
													.getString("ss_player_code4");

											String player1_ifollow_new = player_team_obj
													.getString("player1");
											String player2_ifollow_new = player_team_obj
													.getString("player2");
											String player3_ifollow_new = player_team_obj
													.getString("player3");
											String player4_ifollow_new = player_team_obj
													.getString("player4");

											String game_start_ifollow_new = player_team_obj
													.getString("ss_game_start");

											String team_sport_ifollow_new = player_team_obj
													.getString("ss_team_sport");

											String channel_code1_new = player_team_obj
													.getString("channel_name1");
											String channel_code2_new = player_team_obj
													.getString("channel_name2");
											String channel_code3_new = player_team_obj
													.getString("channel_name3");

											String ticket_url = player_team_obj
													.getString("ss_ticket_url");

											String match_code = player_team_obj
													.getString("ss_match_code");

											String player1_club5 = player_team_obj
													.getString("player1_club5");

											String player2_club5 = player_team_obj
													.getString("player2_club5");

											String player1_country = player_team_obj
													.getString("player1_country");

											String player2_country = player_team_obj
													.getString("player2_country");

											String player3_country = player_team_obj
													.getString("player3_country");

											String player4_country = player_team_obj
													.getString("player4_country");

											String match_text = player_team_obj
													.getString("ss_match_text");

											String game_text = player_team_obj
													.getString("ss_game_text");

											String sport_code = player_team_obj
													.getString("ss_sport_code");

											SimpleDateFormat formatter = new SimpleDateFormat(
													"yyyyMMddHHmmss");
											formatter.setTimeZone(TimeZone
													.getTimeZone("UTC"));
											Date date = (Date) formatter
													.parse(game_start_ifollow_new);

											// Log.e("suraj", "DA==" + date);

											SimpleDateFormat dateFormat = new SimpleDateFormat(
													"dd-MMM hh:mm a");

											String mydate = null;

											dateFormat.setTimeZone(TimeZone
													.getDefault());

											SimpleDateFormat dayFormat = new SimpleDateFormat(
													"EEEE");
											String myday = dayFormat.format(
													date).toUpperCase();
											mydate = dateFormat.format(date);

											SimpleDateFormat dateFormat1 = new SimpleDateFormat(
													"dd-MM-yyyy hh:mm a");

											String mydate1 = null;

											dateFormat1.setTimeZone(TimeZone
													.getDefault());
											mydate1 = dateFormat1.format(date);

											SimpleDateFormat formatter1 = new SimpleDateFormat(
													"yyyyMMddHHmmss");
											formatter1.setTimeZone(TimeZone
													.getTimeZone("UTC"));
											Date date11 = (Date) formatter1.parse(player_team_obj
													.getString("ss_game_start"));

											SimpleDateFormat dateFormat11 = new SimpleDateFormat(
													"EEE dd MMM yyyy");

											String mydate_cs = null;

											dateFormat11.setTimeZone(TimeZone
													.getDefault());

											SimpleDateFormat timeFormat1 = new SimpleDateFormat(
													"HH:mm");

											// String mytime_cs = null;
											// if (ss_match_text == null
											// || ss_match_text.equals("")) {
											// mytime_cs = timeFormat1.format(
											// date11).toUpperCase();
											// } else {
											// mytime_cs = ss_match_text
											// + ":  "
											// + timeFormat1.format(
											// date11)
											// .toUpperCase();
											// }

											mydate_cs = dateFormat11
													.format(date11);

											SimpleDateFormat formatter11 = new SimpleDateFormat(
													"yyyyMMddHHmmss");
											formatter11.setTimeZone(TimeZone
													.getTimeZone("UTC"));
											Date date111 = (Date) formatter11.parse(player_team_obj
													.getString("ss_game_start"));

											SimpleDateFormat dateFormat111 = new SimpleDateFormat(
													"EEE dd MMM yyyy");

											String mydate11 = null;

											dateFormat111.setTimeZone(TimeZone
													.getDefault());

											SimpleDateFormat timeFormat11 = new SimpleDateFormat(
													"HH:mm");
											String mytime = timeFormat11
													.format(date111)
													.toUpperCase();
											mydate11 = dateFormat111
													.format(date111);

											if (i_follow_data == null) {

												Log.d("suraj", "pl_lis == "
														+ pl_list);

												if (pl_list
														.contains(player_code1_new) == true)// ||||||)
												{
													follow_pl = player_code1_new;
												} else if (pl_list
														.contains(player_code2_new) == true) {
													follow_pl = player_code2_new;
												} else if (pl_list
														.contains(player_code3_new) == true) {
													follow_pl = player_code3_new;
												} else if (pl_list
														.contains(player_code4_new) == true) {
													follow_pl = player_code4_new;
												}

												// if(team_sport_ifollow_new.equals("Y")||team_sport_ifollow_new.equals("N"))
												// {
												i_follow_data = cs_code_new
														+ ";"
														+ cs_name_new
														+ ";"
														+ sport_name_new
														+ ";"
														+ sport_code
														+ ";"
														+ team_sport_ifollow_new
														+ ";" + follow_pl + ";"
														+ match_code
														+ ";match,"
														+ player_code1_new
														+ ":"
														+ player1_ifollow_new
														+ ":" + player1_country
														+ ":" + player1_club5
														+ ":"
														+ player_code2_new
														+ ":"
														+ player2_ifollow_new
														+ ":" + player2_country
														+ ":" + player2_club5
														+ ":"
														+ player_code3_new
														+ ":"
														+ player3_ifollow_new
														+ ":"
														+ player_code4_new
														+ ":"
														+ player4_ifollow_new
														+ ";" + myday + ","
														+ mydate + ","
														+ mydate1 + ";"
														+ ticket_url
														+ ";channels,"
														+ channel_code1_new
														+ ":"
														+ channel_code2_new
														+ ":"
														+ channel_code3_new
														+ ";" + game_text
														+ " : " + match_text;

												// Log.d("suraj",
												// "Follow_data = "
												// + i_follow_data);

												ichamp_name_temp = player_team_obj
														.getString("ss_cs_name")
														.toUpperCase();
												count++;

												if (b == player_team_jsonobject
														.size() - 1) {

													String video_info1 = null;

													if (!video_list
															.contains(follow_pl)) {
														video_info1 = follow_pl;
														video_list
																.add(follow_pl);
													} else {
														video_info1 = null;
													}
													new_follow_match
															.add(new new_ifollow_player(
																	i_follow_data,
																	null,
																	team_sport_ifollow_new,
																	video_info1,
																	count));
												}

											} else {

												if (ichamp_name_temp
														.equals(player_team_obj
																.getString(
																		"ss_cs_name")
																.toUpperCase())) {

													ichamp_name_temp = player_team_obj
															.getString(
																	"ss_cs_name")
															.toUpperCase();

													i_follow_data = i_follow_data
															+ ";"
															+ match_code
															+ ";match,"
															+ player_code1_new
															+ ":"
															+ player1_ifollow_new
															+ ":"
															+ player1_country
															+ ":"
															+ player1_club5
															+ ":"
															+ player_code2_new
															+ ":"
															+ player2_ifollow_new
															+ ":"
															+ player2_country
															+ ":"
															+ player2_club5
															+ ":"
															+ player_code3_new
															+ ":"
															+ player3_ifollow_new
															+ ":"
															+ player_code4_new
															+ ":"
															+ player4_ifollow_new
															+ ";"
															+ myday
															+ ","
															+ mydate
															+ ","
															+ mydate1
															+ ";"
															+ ticket_url
															+ ";channels,"
															+ channel_code1_new
															+ ":"
															+ channel_code2_new
															+ ":"
															+ channel_code3_new
															+ ";"
															+ game_text
															+ " : "
															+ match_text;

													count++;

													if (b == player_team_jsonobject
															.size() - 1) {

														String video_info1 = null;

														if (!video_list
																.contains(follow_pl)) {
															video_info1 = follow_pl;
															video_list
																	.add(follow_pl);
														} else {
															video_info1 = null;
														}
														new_follow_match
																.add(new new_ifollow_player(
																		i_follow_data,
																		null,
																		team_sport_ifollow_new,
																		video_info1,
																		count));

													}

												} else {

													String video_info11 = null;

													if (!video_list
															.contains(follow_pl)) {
														video_info11 = follow_pl;
														video_list
																.add(follow_pl);
													} else {
														video_info11 = null;
													}

													new_follow_match
															.add(new new_ifollow_player(
																	i_follow_data,
																	null,
																	team_sport_ifollow_new,
																	video_info11,
																	count));
													Log.d("suraj", "pl_list 2="
															+ pl_list);

													if (pl_list
															.contains(player_code1_new) == true)// ||||||)
													{
														follow_pl = player_code1_new;
													} else if (pl_list
															.contains(player_code2_new) == true) {
														follow_pl = player_code2_new;
													} else if (pl_list
															.contains(player_code3_new) == true) {
														follow_pl = player_code3_new;
													} else if (pl_list
															.contains(player_code4_new) == true) {
														follow_pl = player_code4_new;
													}

													i_follow_data = cs_code_new
															+ ";"
															+ cs_name_new
															+ ";"
															+ sport_name_new
															+ ";"
															+ sport_code
															+ ";"
															+ team_sport_ifollow_new
															+ ";"
															+ follow_pl
															+ ";"
															+ match_code
															+ ";match,"
															+ player_code1_new
															+ ":"
															+ player1_ifollow_new
															+ ":"
															+ player1_country
															+ ":"
															+ player1_club5
															+ ":"
															+ player_code2_new
															+ ":"
															+ player2_ifollow_new
															+ ":"
															+ player2_country
															+ ":"
															+ player2_club5
															+ ":"
															+ player_code3_new
															+ ":"
															+ player3_ifollow_new
															+ ":"
															+ player_code4_new
															+ ":"
															+ player4_ifollow_new
															+ ";" + myday + ","
															+ mydate + ","
															+ mydate1 + ";"
															+ ticket_url
															+ ";channels,"
															+ channel_code1_new
															+ ":"
															+ channel_code2_new
															+ ":"
															+ channel_code3_new
															+ ";" + game_text
															+ " : "
															+ match_text;

													ichamp_name_temp = player_team_obj
															.getString(
																	"ss_cs_name")
															.toUpperCase();
													count = 0;
													count++;

													if (b == player_team_jsonobject
															.size() - 1) {

														String video_info1 = null;

														if (!video_list
																.contains(follow_pl)) {
															video_info1 = follow_pl;
															video_list
																	.add(follow_pl);
														} else {
															video_info1 = null;
														}
														new_follow_match
																.add(new new_ifollow_player(
																		i_follow_data,
																		null,
																		team_sport_ifollow_new,
																		video_info1,
																		count));

													}
												}
											}

										}

										// ///championship//////////

										ArrayList<String> champ_video_list = new ArrayList<String>();

										for (int a = 0; a < champ_jsonobject
												.size(); a++) {

											JSONObject champ_obj = champ_jsonobject
													.get(a);

											String cs_code_new = champ_obj
													.getString("ss_cs_code");

											String cs_name_new = champ_obj
													.getString("ss_cs_name")
													.toUpperCase();

											String sport_name_new = champ_obj
													.getString("ss_sport");

											String player_code1_new = champ_obj
													.getString("ss_player_code1");
											String player_code2_new = champ_obj
													.getString("ss_player_code2");
											String player_code3_new = champ_obj
													.getString("ss_player_code3");
											String player_code4_new = champ_obj
													.getString("ss_player_code4");

											String player1_ifollow_new = champ_obj
													.getString("player1");
											String player2_ifollow_new = champ_obj
													.getString("player2");
											String player3_ifollow_new = champ_obj
													.getString("player3");
											String player4_ifollow_new = champ_obj
													.getString("player4");

											String game_start_ifollow_new = champ_obj
													.getString("ss_game_start");

											String team_sport_ifollow_new = champ_obj
													.getString("ss_team_sport");

											String channel_code1_new = champ_obj
													.getString("channel_name1");
											String channel_code2_new = champ_obj
													.getString("channel_name2");
											String channel_code3_new = champ_obj
													.getString("channel_name3");

											String ticket_url = champ_obj
													.getString("ss_ticket_url");

											String match_code = champ_obj
													.getString("ss_match_code");

											String player1_club5 = champ_obj
													.getString("player1_club5");

											String player2_club5 = champ_obj
													.getString("player2_club5");

											String player1_country = champ_obj
													.getString("player1_country");

											String player2_country = champ_obj
													.getString("player2_country");

											String player3_country = champ_obj
													.getString("player3_country");

											String player4_country = champ_obj
													.getString("player4_country");

											String ss_match_text = champ_obj
													.getString("ss_match_text");

											String game_text = champ_obj
													.getString("ss_game_text");

											String sport_code = champ_obj
													.getString("ss_sport_code");

											SimpleDateFormat formatter = new SimpleDateFormat(
													"yyyyMMddHHmmss");
											formatter.setTimeZone(TimeZone
													.getTimeZone("UTC"));
											Date date = (Date) formatter
													.parse(game_start_ifollow_new);

											// Log.e("suraj", "DA==" + date);

											SimpleDateFormat dateFormat = new SimpleDateFormat(
													"dd-MMM hh:mm a");

											String mydate = null;

											dateFormat.setTimeZone(TimeZone
													.getDefault());

											SimpleDateFormat dayFormat = new SimpleDateFormat(
													"EEEE");
											String myday = dayFormat.format(
													date).toUpperCase();
											mydate = dateFormat.format(date);

											SimpleDateFormat dateFormat1 = new SimpleDateFormat(
													"dd-MM-yyyy hh:mm a");

											String mydate1 = null;

											dateFormat1.setTimeZone(TimeZone
													.getDefault());
											mydate1 = dateFormat1.format(date);

											SimpleDateFormat formatter1 = new SimpleDateFormat(
													"yyyyMMddHHmmss");
											formatter1.setTimeZone(TimeZone
													.getTimeZone("UTC"));
											Date date11 = (Date) formatter1.parse(champ_obj
													.getString("ss_game_start"));

											SimpleDateFormat dateFormat11 = new SimpleDateFormat(
													"EEE dd MMM yyyy");

											String mydate_cs = null;

											dateFormat11.setTimeZone(TimeZone
													.getDefault());

											SimpleDateFormat timeFormat1 = new SimpleDateFormat(
													"hh:mm a");

											String mytime_cs = null;
											if (ss_match_text == null
													|| ss_match_text.equals("")) {
												mytime_cs = timeFormat1.format(
														date11).toUpperCase();
											} else {
												mytime_cs = ss_match_text
														+ ":  "
														+ timeFormat1.format(
																date11)
																.toUpperCase();
											}

											mydate_cs = dateFormat11
													.format(date11);

											SimpleDateFormat formatter11 = new SimpleDateFormat(
													"yyyyMMddHHmmss");
											formatter11.setTimeZone(TimeZone
													.getTimeZone("UTC"));
											Date date111 = (Date) formatter11.parse(champ_obj
													.getString("ss_game_start"));

											SimpleDateFormat dateFormat111 = new SimpleDateFormat(
													"EEE dd MMM yyyy");

											String mydate11 = null;

											dateFormat111.setTimeZone(TimeZone
													.getDefault());

											SimpleDateFormat timeFormat11 = new SimpleDateFormat(
													"HH:mm");
											String mytime = timeFormat11
													.format(date111)
													.toUpperCase();
											mydate11 = dateFormat111
													.format(date111);

											if (i_follow_champ_data == null) {
												i_follow_champ_data = cs_code_new
														+ ";"
														+ cs_name_new
																.toUpperCase()
														+ ";"
														+ sport_name_new
														+ ";"
														+ sport_code
														+ ";"
														+ ticket_url
														+ ","
														+ "match!"
														+ champ_obj.getString(
																"ss_game_text")
																.toUpperCase()
														+ "!channel,"
														+ channel_code1_new
														+ ":"
														+ channel_code2_new
														+ ":"
														+ channel_code3_new
														+ "!"
														+ mydate1
														+ "!"
														+ "date,"
														+ mydate11
														+ "!"
														+ "time,"
														+ mytime_cs;

												chmp_count++;

												new_champ = champ_obj
														.getString("ss_cs_name")
														.toUpperCase();
												new_game = champ_obj.getString(
														"ss_game_text")
														.toUpperCase();
												new_date = mydate11;

												Log.w("abc",
														"i_follow_champ_data = "
																+ i_follow_champ_data);

												if (a == player_team_jsonobject
														.size() - 1) {

													String video_info1 = null;

													if (!champ_video_list
															.contains(cs_code_new
																	+ ":"
																	+ sport_code)) {
														video_info1 = cs_code_new
																+ ":"
																+ sport_code;
														champ_video_list
																.add(cs_code_new
																		+ ":"
																		+ sport_code);
													} else {
														video_info1 = null;
													}
													new_follow_match
															.add(new new_ifollow_player(
																	null,
																	i_follow_champ_data,
																	team_sport_ifollow_new,
																	video_info1,
																	chmp_count));

													// new_follow_match.add(new
													// new_ifollow_player(i_follow_data,null,
													// team_sport_ifollow_new,count));
												}
											} else {
												if (new_champ
														.equals(cs_name_new
																.toUpperCase()) == true) {
													if (new_game
															.equals(champ_obj
																	.getString(
																			"ss_game_text")
																	.toUpperCase()) == true) {
														if (new_date
																.equals(mydate11) == true) {
															i_follow_champ_data = i_follow_champ_data
																	+ "!"
																	+ "time,"
																	+ mytime_cs;

														} else {
															new_date = mydate11;
															new_game = champ_obj
																	.getString(
																			"ss_game_text")
																	.toUpperCase();

															i_follow_champ_data = i_follow_champ_data
																	+ "!"
																	+ "date,"
																	+ mydate11
																	+ "!"
																	+ "time,"
																	+ mytime_cs;

															if (a == champ_jsonobject
																	.size() - 1) {

																String video_info1 = null;

																if (!champ_video_list
																		.contains(cs_code_new
																				+ ":"
																				+ sport_code)) {
																	video_info1 = cs_code_new
																			+ ":"
																			+ sport_code;
																	champ_video_list
																			.add(cs_code_new
																					+ ":"
																					+ sport_code);
																} else {
																	video_info1 = null;
																}
																new_follow_match
																		.add(new new_ifollow_player(
																				null,
																				i_follow_champ_data,
																				team_sport_ifollow_new,
																				video_info1,
																				chmp_count));

															}

														}
													} else {

														i_follow_champ_data = i_follow_champ_data
																+ ";"
																+ ticket_url
																+ ","
																+ "match!"
																+ champ_obj
																		.getString(
																				"ss_game_text")
																		.toUpperCase()
																+ "!channel,"
																+ channel_code1_new
																+ ":"
																+ channel_code2_new
																+ ":"
																+ channel_code3_new
																+ "!"
																+ mydate1
																+ "!"
																+ "date,"
																+ mydate11
																+ "!"
																+ "time,"
																+ mytime_cs;

														new_champ = champ_obj
																.getString(
																		"ss_cs_name")
																.toUpperCase();
														new_game = champ_obj
																.getString(
																		"ss_game_text")
																.toUpperCase();
														new_date = mydate11;

														// chmp_count=0;
														chmp_count++;
													}
												} else {

													String video_info1 = null;

													if (!champ_video_list
															.contains(cs_code_new
																	+ ":"
																	+ sport_code)) {
														video_info1 = cs_code_new
																+ ":"
																+ sport_code;
														champ_video_list
																.add(cs_code_new
																		+ ":"
																		+ sport_code);
													} else {
														video_info1 = null;
													}

													new_follow_match
															.add(new new_ifollow_player(
																	null,
																	i_follow_champ_data,
																	team_sport_ifollow_new,
																	video_info1,
																	chmp_count));

													i_follow_champ_data = cs_code_new
															+ ";"
															+ cs_name_new
																	.toUpperCase()
															+ ";"
															+ sport_name_new
															+ ";"
															+ sport_code
															+ ";"
															+ ticket_url
															+ ","
															+ "match!"
															+ champ_obj
																	.getString(
																			"ss_game_text")
																	.toUpperCase()
															+ "!channel,"
															+ channel_code1_new
															+ ":"
															+ channel_code2_new
															+ ":"
															+ channel_code3_new
															+ "!"
															+ mydate1
															+ "!"
															+ "date,"
															+ mydate11
															+ "!"
															+ "time,"
															+ mytime_cs;

													new_champ = champ_obj
															.getString(
																	"ss_cs_name")
															.toUpperCase();
													new_game = champ_obj
															.getString(
																	"ss_game_text")
															.toUpperCase();
													new_date = mydate11;

													chmp_count = 0;
													chmp_count++;

													if (a == champ_jsonobject
															.size() - 1) {

														String video_info11 = null;

														if (!champ_video_list
																.contains(cs_code_new
																		+ ":"
																		+ sport_code)) {
															video_info11 = cs_code_new
																	+ ":"
																	+ sport_code;
															champ_video_list
																	.add(cs_code_new
																			+ ":"
																			+ sport_code);
														} else {
															video_info11 = null;
														}
														new_follow_match
																.add(new new_ifollow_player(
																		null,
																		i_follow_champ_data,
																		team_sport_ifollow_new,
																		video_info11,
																		chmp_count));

													}
												}
											}
										}
									} catch (Exception e) {
										// TODO: handle exception
										e.printStackTrace();
									}

									// runOnUiThread(new Runnable() {
									// public void run() {

									Log.d("suraj",
											" = " + new_follow_match.size());

									playerAdaptersize = 1;
									if (new_follow_match.size() > 0) {

										Log.d("suraj",
												"champ_list follow not null main");

										upcoming.setBackgroundDrawable(getResources()
												.getDrawable(
														R.drawable.tab_button));
										upcoming.setCompoundDrawablesWithIntrinsicBounds(
												0, 0, R.drawable.arrow_yellow,
												0);
										upcoming.setTextColor(Color
												.parseColor("#FFCC11"));

										i_follow.setBackgroundDrawable(getResources()
												.getDrawable(
														R.drawable.tab_button1));
										i_follow.setCompoundDrawablesWithIntrinsicBounds(
												0, 0, R.drawable.arrow_black_r,
												0);
										i_follow.setTextColor(Color.BLACK);

										all_sport
												.setBackgroundDrawable(getResources()
														.getDrawable(
																R.drawable.tab_button));
										all_sport
												.setCompoundDrawablesWithIntrinsicBounds(
														0,
														0,
														R.drawable.arrow_yellow,
														0);
										all_sport.setTextColor(Color
												.parseColor("#FFCC11"));
									} else {

										upcoming.setBackgroundDrawable(getResources()
												.getDrawable(
														R.drawable.tab_button));
										upcoming.setCompoundDrawablesWithIntrinsicBounds(
												0, 0, R.drawable.arrow_black_r,
												0);
										upcoming.setTextColor(Color.BLACK);

										i_follow.setBackgroundDrawable(getResources()
												.getDrawable(
														R.drawable.tab_button1));
										i_follow.setCompoundDrawablesWithIntrinsicBounds(
												0, 0, R.drawable.arrow_yellow,
												0);
										i_follow.setTextColor(Color
												.parseColor("#FFCC11"));

										all_sport
												.setBackgroundDrawable(getResources()
														.getDrawable(
																R.drawable.tab_button));
										all_sport
												.setCompoundDrawablesWithIntrinsicBounds(
														0,
														0,
														R.drawable.arrow_yellow,
														0);
										all_sport.setTextColor(Color
												.parseColor("#FFCC11"));

										upcoming();

									}

								}
							});
						}
					}).start();
					return null;

				}
			};
			wait.execute();

			if (get_sport_follow.getCount() > 0 || get_sport_follow == null) {
				get_sport_follow.moveToFirst();
				String sport_lt = "";
				String sport = "";
				do {
					sport_lt = get_sport_follow.getString(get_sport_follow
							.getColumnIndex("player_id"));

					sport = get_sport_follow.getString(get_sport_follow
							.getColumnIndex("sport"));

					new_follow_match.add(new new_ifollow_player(null, null,
							null, sport_lt + ":" + sport, 0));

				} while (get_sport_follow.moveToNext());
			}
		}

		upcoming.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				// lv.setAdapter(null);

				search_text.clearFocus();
				search_boolean = false;
				search_text.setText("");

				search_view.setVisibility(View.VISIBLE);
				search_text.setVisibility(View.GONE);
				action_progress.setVisibility(View.GONE);
				app_logo.setVisibility(View.VISIBLE);

				lv.setAdapter(null);

				upcoming();

			}
		});

		button_back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				menu_sport_cs();

			}
		});

		all_sport.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				adView.setVisibility(View.GONE);

				all_sport.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.tab_button1));
				all_sport.setCompoundDrawablesWithIntrinsicBounds(0, 0,
						R.drawable.arrow_black_r, 0);
				all_sport.setTextColor(Color.BLACK);

				String[] new_live = StartActivity.what_new.split(":");

				cs_code_selected = new_live[1];

				br_sport_name = new_live[2];
				team_sports = new_live[3];
				sport_code = new_live[4];

				// br_sport_name = "FOOTBALL";
				// team_sports = "Y";
				// sport_code = "SOC";

				after_cs_select(new_live[0]);

			}
		});

		i_follow.setOnClickListener(new OnClickListener() {

			@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
			@Override
			public void onClick(View v) {

				adView.setVisibility(View.GONE);
				webView1.setVisibility(View.GONE);

				search_text.clearFocus();
				search_boolean = false;
				search_text.setText("");

				search_view.setVisibility(View.VISIBLE);
				search_text.setVisibility(View.GONE);
				action_progress.setVisibility(View.GONE);
				app_logo.setVisibility(View.VISIBLE);

				findViewById(R.id.new_main_real_heading).setVisibility(
						View.GONE);
				findViewById(R.id.new_web_btn_head).setVisibility(View.GONE);
				findViewById(R.id.new_hori_btn_head).setVisibility(View.GONE);
				findViewById(R.id.new_video_bar).setVisibility(View.GONE);

				lv.setEmptyView(null);
				empty.setVisibility(View.GONE);

				// dataAdapter.close();
				dataAdapter.open();
				int f_count = dataAdapter.total_follow();
				search_text.clearFocus();

				// rel.setVisibility(View.GONE);
				// br_layout_2.setVisibility(View.GONE);

				Log.v("suraj", "TOTAL FOLLOW = " + f_count);

				// search_text.setEnabled(true);
				MainActivity.this
						.getWindow()
						.setSoftInputMode(
								WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

				new_follow_match = new ArrayList<new_ifollow_player>();

				final new_Player_adapter pladpt = new new_Player_adapter(
						MainActivity.this, new_follow_match, null, null, null,
						null);
				lv.setAdapter(pladpt);
				// pladpt.notifyDataSetChanged();

				AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

					@Override
					protected void onPostExecute(Void result) {
						// TODO Auto-generated method stub
						super.onPostExecute(result);
						pladpt.notifyDataSetChanged();
						action_progress.setVisibility(View.GONE);
					}

					@Override
					protected void onPreExecute() {
						action_progress.setVisibility(View.VISIBLE);
						super.onPreExecute();
					}

					@Override
					protected Void doInBackground(Void... params) {

						new Thread(new Runnable() {
							@Override
							public void run() {
								lv.setOnScrollListener(null);

								try {
									String selection = " " + Events.DESCRIPTION
											+ " = 'SPORTIZZA'";

									int del = 0;
									if (Integer
											.parseInt(android.os.Build.VERSION.SDK) >= 14) {
										Uri eventsUri = Uri
												.parse("content://com.android.calendar/events");
										del = context.getContentResolver()
												.delete(eventsUri, selection,
														null);

										Log.w("suraj", "deleted row = " + del);
									} else if (Integer
											.parseInt(android.os.Build.VERSION.SDK) >= 8
											&& Integer
													.parseInt(android.os.Build.VERSION.SDK) < 14) {
										Uri eventsUri = Uri
												.parse("content://com.android.calendar/events");

										del = context.getContentResolver()
												.delete(eventsUri, selection,
														null);

										Log.w("suraj", "deleted row = " + del);

									}

								} catch (Exception e) {
								}

								// lv.setAdapter(null);
								boolean i_foll = true;

								runOnUiThread(new Runnable() {

									@Override
									public void run() {

										String i_follow_data = null;
										String i_follow_champ_data = null, new_champ = null, new_game = null, new_date = null;
										String ichamp_name_temp = null;

										String player_list12 = "";
										String champ_list12 = "";
										String sport_list = "";
										String sport = "";

										ArrayList<String> player_lt1 = new ArrayList<String>();
										ArrayList<String> champ_lt1 = new ArrayList<String>();

										dataAdapter.open();

										Cursor get_all_follow = dataAdapter
												.getfollowerlist();
										startManagingCursor(get_all_follow);

										Cursor get_champ_follow = dataAdapter
												.getchamplist();
										startManagingCursor(get_champ_follow);

										if (get_champ_follow != null
												&& get_champ_follow.getCount() > 0) {

											get_champ_follow.moveToFirst();

											do {
												champ_list12 = get_champ_follow
														.getString(get_champ_follow
																.getColumnIndex("player_id"))
														+ "," + champ_list12;

												champ_lt1.add(get_champ_follow
														.getString(get_champ_follow
																.getColumnIndex("player_id")));

											} while (get_champ_follow
													.moveToNext());

											champ_list12 = champ_list12
													.substring(0, champ_list12
															.length() - 1);

											Log.w("suraj", "champ= "
													+ champ_list12);

										} else {
											Log.w("suraj", "champ Follow Null");
											champ_list12 = "-1";
										}

										if (get_all_follow != null
												&& get_all_follow.getCount() > 0) {

											get_all_follow.moveToFirst();

											do {
												player_list12 = get_all_follow
														.getString(get_all_follow
																.getColumnIndex("player_id"))
														+ "," + player_list12;

												player_lt1.add(get_all_follow
														.getString(get_all_follow
																.getColumnIndex("player_id")));

											} while (get_all_follow
													.moveToNext());

											player_list12 = player_list12
													.substring(0, player_list12
															.length() - 1);

											Log.v("suraj",
													"player_list player_lt1 = "
															+ player_lt1);

										} else {
											Log.w("suraj",
													"player/team Follow Null");

											player_list12 = "-1";
										}

										Cursor get_sport_follow = dataAdapter
												.getsportfollow();
										startManagingCursor(get_sport_follow);

										get_all_follow.close();
										get_champ_follow.close();

										if (player_list12.equals("-1")
												&& champ_list12.equals("-1")) {
											// new_follow_match = new
											// ArrayList<new_ifollow_player>();

											if (get_sport_follow != null
													&& get_sport_follow
															.getCount() > 0) {
												// int cursor_count=0;
												get_sport_follow.moveToFirst();

												do {
													sport_list = get_sport_follow
															.getString(get_sport_follow
																	.getColumnIndex("player_id"));
													sport = get_sport_follow
															.getString(get_sport_follow
																	.getColumnIndex("sport"));

													new_follow_match
															.add(new new_ifollow_player(
																	null,
																	null,
																	null,
																	sport_list
																			+ ":"
																			+ sport,
																	0));

												} while (get_sport_follow
														.moveToNext());

											} else {
												sport_list = "-1";
											}
											// get_sport_follow.close();

											upcoming.setBackgroundDrawable(getResources()
													.getDrawable(
															R.drawable.tab_button));
											upcoming.setCompoundDrawablesWithIntrinsicBounds(
													0, 0,
													R.drawable.arrow_yellow, 0);
											upcoming.setTextColor(Color
													.parseColor("#FFCC11"));

											i_follow.setBackgroundDrawable(getResources()
													.getDrawable(
															R.drawable.tab_button1));
											i_follow.setCompoundDrawablesWithIntrinsicBounds(
													0, 0,
													R.drawable.arrow_black_r, 0);
											i_follow.setTextColor(Color.BLACK);

											all_sport
													.setBackgroundDrawable(getResources()
															.getDrawable(
																	R.drawable.tab_button));
											all_sport
													.setCompoundDrawablesWithIntrinsicBounds(
															0,
															0,
															R.drawable.arrow_yellow,
															0);
											all_sport.setTextColor(Color
													.parseColor("#FFCC11"));

										} else {

											String i_fol_url = "http://www.sportizza.com/interface/ios_all_follow_new.php?iso_cd="
													+ country_code
													+ "&follow="
													+ player_list12
													+ "&follow_cs="
													+ champ_list12
													+ "&follow_sport=-1";

											// String i_fol_url
											// ="http://sportizza.com/interface/ios_next.php?next_hr=4&dt_time=201405300346&iso_cd=in";

											try {
												String Json_result = Utils
														.readJsonFeed(
																i_fol_url,
																MainActivity.this);

												JSONArray array_ifollow_new = new JSONArray(
														Json_result);

												int json_len = array_ifollow_new
														.length();

												ArrayList<JSONObject> champ_jsonobject = new ArrayList<JSONObject>();

												ArrayList<JSONObject> player_team_jsonobject = new ArrayList<JSONObject>();

												for (int i = 0; i < json_len; i++) {
													JSONObject JsonObject_ifollow_new = array_ifollow_new
															.getJSONObject(i);

													String team_sport_ifollow_new = JsonObject_ifollow_new
															.getString("ss_team_sport");

													if (team_sport_ifollow_new
															.equals("A")) {
														champ_jsonobject
																.add(JsonObject_ifollow_new);
													} else {
														player_team_jsonobject
																.add(JsonObject_ifollow_new);
													}

												}

												Log.e("suraj",
														" Array Json Champ size ="
																+ champ_jsonobject
																		.size());
												Log.w("suraj",
														" Array Json Player size ="
																+ player_team_jsonobject
																		.size());

												// //////////player_team
												// /////////////

												ArrayList<String> temp_video_List = new ArrayList<String>();

												int count = 0;
												int chmp_count = 0;

												for (int b = 0; b < player_team_jsonobject
														.size(); b++) {

													JSONObject player_team_obj = player_team_jsonobject
															.get(b);

													String cs_code_new = player_team_obj
															.getString("ss_cs_code");

													String cs_name_new = player_team_obj
															.getString(
																	"ss_cs_name")
															.toUpperCase();

													String sport_name_new = player_team_obj
															.getString("ss_sport");

													String player_code1_new = player_team_obj
															.getString("ss_player_code1");
													String player_code2_new = player_team_obj
															.getString("ss_player_code2");
													String player_code3_new = player_team_obj
															.getString("ss_player_code3");
													String player_code4_new = player_team_obj
															.getString("ss_player_code4");

													String player1_ifollow_new = player_team_obj
															.getString("player1");
													String player2_ifollow_new = player_team_obj
															.getString("player2");
													String player3_ifollow_new = player_team_obj
															.getString("player3");
													String player4_ifollow_new = player_team_obj
															.getString("player4");

													String game_start_ifollow_new = player_team_obj
															.getString("ss_game_start");

													String team_sport_ifollow_new = player_team_obj
															.getString("ss_team_sport");

													String channel_code1_new = player_team_obj
															.getString("channel_name1");
													String channel_code2_new = player_team_obj
															.getString("channel_name2");
													String channel_code3_new = player_team_obj
															.getString("channel_name3");

													String ticket_url = player_team_obj
															.getString("ss_ticket_url");

													String match_code = player_team_obj
															.getString("ss_match_code");

													String player1_club5 = player_team_obj
															.getString("player1_club5");

													String player2_club5 = player_team_obj
															.getString("player2_club5");

													String player1_country = player_team_obj
															.getString("player1_country");

													String player2_country = player_team_obj
															.getString("player2_country");

													String player3_country = player_team_obj
															.getString("player3_country");

													String player4_country = player_team_obj
															.getString("player4_country");

													String match_text = player_team_obj
															.getString("ss_match_text");

													String game_text = player_team_obj
															.getString("ss_game_text");

													String sport_code = player_team_obj
															.getString("ss_sport_code");

													SimpleDateFormat formatter = new SimpleDateFormat(
															"yyyyMMddHHmmss");
													formatter
															.setTimeZone(TimeZone
																	.getTimeZone("UTC"));
													Date date = (Date) formatter
															.parse(game_start_ifollow_new);

													// Log.e("suraj", "DA==" +
													// date);

													SimpleDateFormat dateFormat = new SimpleDateFormat(
															"dd-MMM hh:mm a");

													String mydate = null;

													dateFormat
															.setTimeZone(TimeZone
																	.getDefault());

													SimpleDateFormat dayFormat = new SimpleDateFormat(
															"EEEE");
													String myday = dayFormat
															.format(date)
															.toUpperCase();
													mydate = dateFormat
															.format(date);

													SimpleDateFormat dateFormat1 = new SimpleDateFormat(
															"dd-MM-yyyy hh:mm a");

													String mydate1 = null;

													dateFormat1
															.setTimeZone(TimeZone
																	.getDefault());
													mydate1 = dateFormat1
															.format(date);

													SimpleDateFormat formatter1 = new SimpleDateFormat(
															"yyyyMMddHHmmss");
													formatter1
															.setTimeZone(TimeZone
																	.getTimeZone("UTC"));
													Date date11 = (Date) formatter1
															.parse(player_team_obj
																	.getString("ss_game_start"));

													SimpleDateFormat dateFormat11 = new SimpleDateFormat(
															"EEE dd MMM yyyy");

													String mydate_cs = null;

													dateFormat11
															.setTimeZone(TimeZone
																	.getDefault());

													SimpleDateFormat timeFormat1 = new SimpleDateFormat(
															"HH:mm");

													// String mytime_cs = null;
													// if (ss_match_text == null
													// ||
													// ss_match_text.equals(""))
													// {
													// mytime_cs =
													// timeFormat1.format(
													// date11).toUpperCase();
													// } else {
													// mytime_cs = ss_match_text
													// + ":  "
													// + timeFormat1.format(
													// date11)
													// .toUpperCase();
													// }

													mydate_cs = dateFormat11
															.format(date11);

													SimpleDateFormat formatter11 = new SimpleDateFormat(
															"yyyyMMddHHmmss");
													formatter11
															.setTimeZone(TimeZone
																	.getTimeZone("UTC"));
													Date date111 = (Date) formatter11
															.parse(player_team_obj
																	.getString("ss_game_start"));

													SimpleDateFormat dateFormat111 = new SimpleDateFormat(
															"EEE dd MMM yyyy");

													String mydate11 = null;

													dateFormat111
															.setTimeZone(TimeZone
																	.getDefault());

													SimpleDateFormat timeFormat11 = new SimpleDateFormat(
															"HH:mm");
													String mytime = timeFormat11
															.format(date111)
															.toUpperCase();
													mydate11 = dateFormat111
															.format(date111);

													// ////////////// calendar
													// //////////////
													dataAdapter.open();
													String calal = dataAdapter
															.getcalValue();
													dataAdapter.close();
													Log.d("suraj",
															"CAL VALUE ="
																	+ calal);

													if (calal.equals("Y")) {

														Long start_date_mili = null;

														String title = null;
														String Desc = null;
														String event_color = null;
														if (team_sport_ifollow_new
																.equals("N")) {

															if (game_text
																	.contains("Double") == true) {
																title = player1_ifollow_new
																		+ " / "
																		+ player3_ifollow_new
																		+ " Vs "
																		+ player2_ifollow_new
																		+ " / "
																		+ player4_ifollow_new
																		+ " - "
																		+ cs_name_new;
															} else {
																title = player1_ifollow_new
																		+ " Vs "
																		+ player2_ifollow_new
																		+ " - "
																		+ cs_name_new;
															}

															Desc = "SPORTIZZA";
															event_color = "Color.RED";

														} else if (team_sport_ifollow_new
																.equals("Y")) {
															title = player1_ifollow_new
																	+ " Vs "
																	+ player2_ifollow_new
																	+ " - "
																	+ cs_name_new;

															Desc = "SPORTIZZA";
															event_color = "Color.BLUE";

														}

														SimpleDateFormat dateFormat11i = new SimpleDateFormat(
																"dd-MM-yyyy hh:mm a");

														String date_addi = null;
														Date date11i = null;

														try {
															date11i = dateFormat11i
																	.parse(mydate1);
														} catch (ParseException e) {
															e.printStackTrace();
														}

														SimpleDateFormat dateFormat_day_ifollow = new SimpleDateFormat(
																"dd-MM-yyyy");

														date_addi = dateFormat_day_ifollow
																.format(date11i);

														try {
															String string1 = date_addi
																	+ " 12:00 AM";
															Date time1 = new SimpleDateFormat(
																	"dd-MM-yyyy hh:mm a")
																	.parse(string1);
															Calendar calendar1 = Calendar
																	.getInstance();
															calendar1
																	.setTime(time1);

															String string2 = date_addi
																	+ " 06:00 AM";
															Date time2 = new SimpleDateFormat(
																	"dd-MM-yyyy hh:mm a")
																	.parse(string2);
															Calendar calendar2 = Calendar
																	.getInstance();
															calendar2
																	.setTime(time2);
															// calendar2.add(Calendar.DATE,
															// 1);

															Date d = new SimpleDateFormat(
																	"dd-MM-yyyy hh:mm a")
																	.parse(mydate1);
															Calendar calendar3 = Calendar
																	.getInstance();
															calendar3
																	.setTime(d);
															// calendar3.add(Calendar.DATE,
															// 1);

															Date x = calendar3
																	.getTime();

															if (x.after(calendar1
																	.getTime())
																	&& x.before(calendar2
																			.getTime())) {
																// checkes
																// whether the
																// current time
																// is
																// between 12.00
																// and 6.00.
																Log.i("suraj",
																		"Between Time");

																String sample_date = date_addi
																		+ " 10:00 PM";
																Date time3 = new SimpleDateFormat(
																		"dd-MM-yyyy hh:mm a")
																		.parse(sample_date);
																Calendar calendar4 = Calendar
																		.getInstance();
																calendar4
																		.setTime(time3);
																calendar4
																		.add(Calendar.DATE,
																				-1);

																start_date_mili = calendar4
																		.getTimeInMillis();

																// Calendar
																// cal1=Calendar.getInstance();
																// cal1.setTimeInMillis(start_date_mili);

																title = title
																		+ " Start at "
																		+ mydate1
																		+ "";
															} else {
																Log.i("suraj",
																		"Not Between Time");

																Log.d("suraj",
																		"CAL DATE = "
																				+ d);

																start_date_mili = d
																		.getTime();

															}

															long begin = start_date_mili;
															long end = start_date_mili + 30 * 60 * 1000;// ending
																										// time
																										// in
																										// milliseconds

															String[] proj = new String[] {
																	Instances._ID,
																	Instances.BEGIN,
																	Instances.END,
																	Instances.EVENT_ID };

															Cursor cursor;

															if (Integer
																	.parseInt(android.os.Build.VERSION.SDK) <= 10) {
																ContentResolver cr = act
																		.getContentResolver();

																cursor = cr
																		.query(Uri
																				.parse("content://calendar/calendars"),
																				proj,
																				null,
																				null,
																				null);

																cursor.moveToFirst();
															} else {
																cursor = Instances
																		.query(act
																				.getContentResolver(),
																				proj,
																				begin,
																				end);

																cursor.moveToFirst();
															}

															if (cursor
																	.getCount() > 0) {

																String title_cal = cursor
																		.getString(cursor
																				.getColumnIndex("title"));

																if (title_cal
																		.equals(title)) {
																	// Toast.makeText(act_context,
																	// "Already Added to Calender..",
																	// Toast.LENGTH_SHORT).show();
																} else {
																	Log.i("suraj",
																			"Add to calendar = "
																					+ title);

																	addToCalendar_ifollow(
																			act,
																			title,
																			Desc,
																			start_date_mili,
																			end,
																			event_color);
																}
															} else {

																Log.i("suraj",
																		"Add to calendar = "
																				+ title);

																addToCalendar_ifollow(
																		act,
																		title,
																		Desc,
																		start_date_mili,
																		end,
																		event_color);
																// Toast.makeText(act_context,
																// "Added to Calender..",
																// Toast.LENGTH_SHORT).show();

															}
														} catch (Exception e) {
															e.printStackTrace();
														}
													}
													// ////////////////////////////////////

													// String follow_pl = null;
													if (i_follow_data == null) {

														if (player_lt1
																.contains(player_code1_new) == true)// ||||||)
														{
															follow_pl = player_code1_new;
														} else if (player_lt1
																.contains(player_code2_new) == true) {
															follow_pl = player_code2_new;
														} else if (player_lt1
																.contains(player_code3_new) == true) {
															follow_pl = player_code3_new;
														} else if (player_lt1
																.contains(player_code4_new) == true) {
															follow_pl = player_code4_new;
														}

														// if(team_sport_ifollow_new.equals("Y")||team_sport_ifollow_new.equals("N"))
														// {

														i_follow_data = cs_code_new
																+ ";"
																+ cs_name_new
																+ ";"
																+ sport_name_new
																+ ";"
																+ sport_code
																+ ";"
																+ team_sport_ifollow_new
																+ ";"
																+ follow_pl
																+ ";"
																+ match_code
																+ ";match,"
																+ player_code1_new
																+ ":"
																+ player1_ifollow_new
																+ ":"
																+ player1_country
																+ ":"
																+ player1_club5
																+ ":"
																+ player_code2_new
																+ ":"
																+ player2_ifollow_new
																+ ":"
																+ player2_country
																+ ":"
																+ player2_club5
																+ ":"
																+ player_code3_new
																+ ":"
																+ player3_ifollow_new
																+ ":"
																+ player_code4_new
																+ ":"
																+ player4_ifollow_new
																+ ";"
																+ myday
																+ ","
																+ mydate
																+ ","
																+ mydate1
																+ ";"
																+ ticket_url
																+ ";channels,"
																+ channel_code1_new
																+ ":"
																+ channel_code2_new
																+ ":"
																+ channel_code3_new
																+ ";"
																+ game_text
																+ " : "
																+ match_text;

														ichamp_name_temp = player_team_obj
																.getString(
																		"ss_cs_name")
																.toUpperCase();
														count++;

														if (b == player_team_jsonobject
																.size() - 1) {

															String video_info = null;

															if (!temp_video_List
																	.contains(follow_pl)) {
																video_info = follow_pl;
																temp_video_List
																		.add(follow_pl);
															} else {
																video_info = null;
															}

															new_follow_match
																	.add(new new_ifollow_player(
																			i_follow_data,
																			null,
																			team_sport_ifollow_new,
																			video_info,
																			count));

														}
													} else {

														if (ichamp_name_temp
																.equals(player_team_obj
																		.getString(
																				"ss_cs_name")
																		.toUpperCase())) {

															ichamp_name_temp = player_team_obj
																	.getString(
																			"ss_cs_name")
																	.toUpperCase();

															i_follow_data = i_follow_data
																	+ ";"
																	+ match_code
																	+ ";match,"
																	+ player_code1_new
																	+ ":"
																	+ player1_ifollow_new
																	+ ":"
																	+ player1_country
																	+ ":"
																	+ player1_club5
																	+ ":"
																	+ player_code2_new
																	+ ":"
																	+ player2_ifollow_new
																	+ ":"
																	+ player2_country
																	+ ":"
																	+ player2_club5
																	+ ":"
																	+ player_code3_new
																	+ ":"
																	+ player3_ifollow_new
																	+ ":"
																	+ player_code4_new
																	+ ":"
																	+ player4_ifollow_new
																	+ ";"
																	+ myday
																	+ ","
																	+ mydate
																	+ ","
																	+ mydate1
																	+ ";"
																	+ ticket_url
																	+ ";channels,"
																	+ channel_code1_new
																	+ ":"
																	+ channel_code2_new
																	+ ":"
																	+ channel_code3_new
																	+ ";"
																	+ game_text
																	+ " : "
																	+ match_text;

															count++;

															if (b == player_team_jsonobject
																	.size() - 1) {

																String video_info = null;

																if (!temp_video_List
																		.contains(follow_pl)) {
																	video_info = follow_pl;
																	temp_video_List
																			.add(follow_pl);
																} else {
																	video_info = null;
																}

																new_follow_match
																		.add(new new_ifollow_player(
																				i_follow_data,
																				null,
																				team_sport_ifollow_new,
																				video_info,
																				count));
															}

														} else {

															String video_info = null;

															if (!temp_video_List
																	.contains(follow_pl)) {
																video_info = follow_pl;
																temp_video_List
																		.add(follow_pl);
															} else {
																video_info = null;
															}

															new_follow_match
																	.add(new new_ifollow_player(
																			i_follow_data,
																			null,
																			team_sport_ifollow_new,
																			video_info,
																			count));

															// new_follow_match
															// .add(new
															// new_ifollow_player(
															// i_follow_data,
															// null,
															// team_sport_ifollow_new,
															// count));

															if (player_lt1
																	.contains(player_code1_new) == true)// ||||||)
															{
																follow_pl = player_code1_new;
															} else if (player_lt1
																	.contains(player_code2_new) == true) {
																follow_pl = player_code2_new;
															} else if (player_lt1
																	.contains(player_code3_new) == true) {
																follow_pl = player_code3_new;
															} else if (player_lt1
																	.contains(player_code4_new) == true) {
																follow_pl = player_code4_new;
															}

															i_follow_data = cs_code_new
																	+ ";"
																	+ cs_name_new
																	+ ";"
																	+ sport_name_new
																	+ ";"
																	+ sport_code
																	+ ";"
																	+ team_sport_ifollow_new
																	+ ";"
																	+ follow_pl
																	+ ";"
																	+ match_code
																	+ ";match,"
																	+ player_code1_new
																	+ ":"
																	+ player1_ifollow_new
																	+ ":"
																	+ player1_country
																	+ ":"
																	+ player1_club5
																	+ ":"
																	+ player_code2_new
																	+ ":"
																	+ player2_ifollow_new
																	+ ":"
																	+ player2_country
																	+ ":"
																	+ player2_club5
																	+ ":"
																	+ player_code3_new
																	+ ":"
																	+ player3_ifollow_new
																	+ ":"
																	+ player_code4_new
																	+ ":"
																	+ player4_ifollow_new
																	+ ";"
																	+ myday
																	+ ","
																	+ mydate
																	+ ","
																	+ mydate1
																	+ ";"
																	+ ticket_url
																	+ ";channels,"
																	+ channel_code1_new
																	+ ":"
																	+ channel_code2_new
																	+ ":"
																	+ channel_code3_new
																	+ ";"
																	+ game_text
																	+ " : "
																	+ match_text;

															ichamp_name_temp = player_team_obj
																	.getString(
																			"ss_cs_name")
																	.toUpperCase();
															count = 0;
															count++;
															if (b == player_team_jsonobject
																	.size() - 1) {

																String video_info1 = null;

																if (!temp_video_List
																		.contains(follow_pl)) {
																	video_info1 = follow_pl;
																	temp_video_List
																			.add(follow_pl);
																} else {
																	video_info1 = null;
																}

																new_follow_match
																		.add(new new_ifollow_player(
																				i_follow_data,
																				null,
																				team_sport_ifollow_new,
																				video_info1,
																				count));

																// new_follow_match.add(new
																// new_ifollow_player(i_follow_data,null,
																// team_sport_ifollow_new,count));
															}
														}
													}

												}

												// ///championship//////////

												ArrayList<String> temp_video_champ_List = new ArrayList<String>();
												// .add(follow_pl+":"+cs_code_new+":"+sport_code);

												for (int a = 0; a < champ_jsonobject
														.size(); a++) {

													JSONObject champ_obj = champ_jsonobject
															.get(a);

													String cs_code_new = champ_obj
															.getString("ss_cs_code");

													String cs_name_new = champ_obj
															.getString(
																	"ss_cs_name")
															.toUpperCase();

													String sport_name_new = champ_obj
															.getString("ss_sport");

													String player_code1_new = champ_obj
															.getString("ss_player_code1");
													String player_code2_new = champ_obj
															.getString("ss_player_code2");
													String player_code3_new = champ_obj
															.getString("ss_player_code3");
													String player_code4_new = champ_obj
															.getString("ss_player_code4");

													String player1_ifollow_new = champ_obj
															.getString("player1");
													String player2_ifollow_new = champ_obj
															.getString("player2");
													String player3_ifollow_new = champ_obj
															.getString("player3");
													String player4_ifollow_new = champ_obj
															.getString("player4");

													String game_start_ifollow_new = champ_obj
															.getString("ss_game_start");

													String team_sport_ifollow_new = champ_obj
															.getString("ss_team_sport");

													String channel_code1_new = champ_obj
															.getString("channel_name1");
													String channel_code2_new = champ_obj
															.getString("channel_name2");
													String channel_code3_new = champ_obj
															.getString("channel_name3");

													String ticket_url = champ_obj
															.getString("ss_ticket_url");

													String match_code = champ_obj
															.getString("ss_match_code");

													String player1_club5 = champ_obj
															.getString("player1_club5");

													String player2_club5 = champ_obj
															.getString("player2_club5");

													String player1_country = champ_obj
															.getString("player1_country");

													String player2_country = champ_obj
															.getString("player2_country");

													String player3_country = champ_obj
															.getString("player3_country");

													String player4_country = champ_obj
															.getString("player4_country");

													String ss_match_text = champ_obj
															.getString("ss_match_text");

													String game_text = champ_obj
															.getString("ss_game_text");

													String sport_code = champ_obj
															.getString("ss_sport_code");

													SimpleDateFormat formatter = new SimpleDateFormat(
															"yyyyMMddHHmmss");
													formatter
															.setTimeZone(TimeZone
																	.getTimeZone("UTC"));
													Date date = (Date) formatter
															.parse(game_start_ifollow_new);

													// Log.e("suraj", "DA==" +
													// date);

													SimpleDateFormat dateFormat = new SimpleDateFormat(
															"dd-MMM hh:mm a");

													String mydate = null;

													dateFormat
															.setTimeZone(TimeZone
																	.getDefault());

													SimpleDateFormat dayFormat = new SimpleDateFormat(
															"EEEE");
													String myday = dayFormat
															.format(date)
															.toUpperCase();
													mydate = dateFormat
															.format(date);

													SimpleDateFormat dateFormat1 = new SimpleDateFormat(
															"dd-MM-yyyy hh:mm a");

													String mydate1 = null;

													dateFormat1
															.setTimeZone(TimeZone
																	.getDefault());
													mydate1 = dateFormat1
															.format(date);

													SimpleDateFormat formatter1 = new SimpleDateFormat(
															"yyyyMMddHHmmss");
													formatter1
															.setTimeZone(TimeZone
																	.getTimeZone("UTC"));
													Date date11 = (Date) formatter1.parse(champ_obj
															.getString("ss_game_start"));

													SimpleDateFormat dateFormat11 = new SimpleDateFormat(
															"EEE dd MMM yyyy");

													String mydate_cs = null;

													dateFormat11
															.setTimeZone(TimeZone
																	.getDefault());

													SimpleDateFormat timeFormat1 = new SimpleDateFormat(
															"hh:mm a");

													String mytime_cs = null;
													if (ss_match_text == null
															|| ss_match_text
																	.equals("")) {
														mytime_cs = timeFormat1
																.format(date11)
																.toUpperCase();
													} else {
														mytime_cs = ss_match_text
																+ ":  "
																+ timeFormat1
																		.format(date11)
																		.toUpperCase();
													}

													mydate_cs = dateFormat11
															.format(date11);

													SimpleDateFormat formatter11 = new SimpleDateFormat(
															"yyyyMMddHHmmss");
													formatter11
															.setTimeZone(TimeZone
																	.getTimeZone("UTC"));
													Date date111 = (Date) formatter11.parse(champ_obj
															.getString("ss_game_start"));

													SimpleDateFormat dateFormat111 = new SimpleDateFormat(
															"EEE dd MMM yyyy");

													String mydate11 = null;

													dateFormat111
															.setTimeZone(TimeZone
																	.getDefault());

													SimpleDateFormat timeFormat11 = new SimpleDateFormat(
															"HH:mm");
													String mytime = timeFormat11
															.format(date111)
															.toUpperCase();
													mydate11 = dateFormat111
															.format(date111);

													if (i_follow_champ_data == null) {
														i_follow_champ_data = cs_code_new
																+ ";"
																+ cs_name_new
																		.toUpperCase()
																+ ";"
																+ sport_name_new
																+ ";"
																+ sport_code
																+ ";"
																+ ticket_url
																+ ","
																+ "match!"
																+ champ_obj
																		.getString(
																				"ss_game_text")
																		.toUpperCase()
																+ "!channel,"
																+ channel_code1_new
																+ ":"
																+ channel_code2_new
																+ ":"
																+ channel_code3_new
																+ "!"
																+ mydate1
																+ "!"
																+ "date,"
																+ mydate11
																+ "!"
																+ "time,"
																+ mytime_cs;

														chmp_count++;

														new_champ = champ_obj
																.getString(
																		"ss_cs_name")
																.toUpperCase();
														new_game = champ_obj
																.getString(
																		"ss_game_text")
																.toUpperCase();
														new_date = mydate11;

														Log.w("abc",
																"i_follow_champ_data = "
																		+ i_follow_champ_data);

														if (a == champ_jsonobject
																.size() - 1) {

															String video_info = null;

															if (!temp_video_champ_List
																	.contains(cs_code_new
																			+ ":"
																			+ sport_code)) {
																video_info = cs_code_new
																		+ ":"
																		+ sport_code;
																temp_video_champ_List
																		.add(cs_code_new
																				+ ":"
																				+ sport_code);
															} else {
																video_info = null;
															}

															new_follow_match
																	.add(new new_ifollow_player(
																			null,
																			i_follow_champ_data,
																			team_sport_ifollow_new,
																			video_info,
																			chmp_count));

														}

														// /////calendar///////////

														dataAdapter.open();
														String calal = dataAdapter
																.getcalValue();
														dataAdapter.close();

														if (calal.equals("Y")) {
															Long start_date_mili = null;
															String title = champ_obj
																	.getString(
																			"ss_game_text")
																	.toUpperCase()
																	+ " - "
																	+ cs_name_new;
															String Desc = "SPORTIZZA";
															String event_color = "Color.GREEN";

															SimpleDateFormat dateFormat11i = new SimpleDateFormat(
																	"dd-MM-yyyy hh:mm a");

															String date_addi = null;
															Date date11i = null;

															try {
																date11i = dateFormat11i
																		.parse(mydate1);
															} catch (ParseException e) {
																e.printStackTrace();
															}

															SimpleDateFormat dateFormat_day_ifollow = new SimpleDateFormat(
																	"dd-MM-yyyy");

															date_addi = dateFormat_day_ifollow
																	.format(date11i);

															try {
																String string1 = date_addi
																		+ " 12:00 AM";
																Date time1 = new SimpleDateFormat(
																		"dd-MM-yyyy hh:mm a")
																		.parse(string1);
																Calendar calendar1 = Calendar
																		.getInstance();
																calendar1
																		.setTime(time1);

																String string2 = date_addi
																		+ " 06:00 AM";
																Date time2 = new SimpleDateFormat(
																		"dd-MM-yyyy hh:mm a")
																		.parse(string2);
																Calendar calendar2 = Calendar
																		.getInstance();
																calendar2
																		.setTime(time2);
																// calendar2.add(Calendar.DATE,
																// 1);

																Date d = new SimpleDateFormat(
																		"dd-MM-yyyy hh:mm a")
																		.parse(mydate1);
																Calendar calendar3 = Calendar
																		.getInstance();
																calendar3
																		.setTime(d);
																// calendar3.add(Calendar.DATE,
																// 1);

																Date x = calendar3
																		.getTime();

																if (x.after(calendar1
																		.getTime())
																		&& x.before(calendar2
																				.getTime())) {
																	// checkes
																	// whether
																	// the
																	// current
																	// time is
																	// between
																	// 12.00 and
																	// 6.00.
																	Log.i("suraj",
																			"Between Time");

																	String sample_date = date_addi
																			+ " 10:00 PM";
																	Date time3 = new SimpleDateFormat(
																			"dd-MM-yyyy hh:mm a")
																			.parse(sample_date);
																	Calendar calendar4 = Calendar
																			.getInstance();
																	calendar4
																			.setTime(time3);
																	calendar4
																			.add(Calendar.DATE,
																					-1);

																	start_date_mili = calendar4
																			.getTimeInMillis();

																	// Calendar
																	// cal1=Calendar.getInstance();
																	// cal1.setTimeInMillis(start_date_mili);

																	title = title
																			+ " Start at "
																			+ mydate1
																			+ "";
																} else {
																	Log.i("suraj",
																			"Not Between Time");

																	Log.d("suraj",
																			"CAL DATE = "
																					+ d);

																	start_date_mili = d
																			.getTime();

																}

																long begin = start_date_mili;
																long end = start_date_mili + 30 * 60 * 1000;// ending
																											// time
																											// in
																											// milliseconds

																String[] proj = new String[] {
																		Instances._ID,
																		Instances.BEGIN,
																		Instances.END,
																		Instances.EVENT_ID };

																Cursor cursor;

																if (Integer
																		.parseInt(android.os.Build.VERSION.SDK) <= 10) {
																	ContentResolver cr = act
																			.getContentResolver();

																	cursor = cr
																			.query(Uri
																					.parse("content://calendar/calendars"),
																					proj,
																					null,
																					null,
																					null);

																	cursor.moveToFirst();
																} else {
																	cursor = Instances
																			.query(act
																					.getContentResolver(),
																					proj,
																					begin,
																					end);

																	cursor.moveToFirst();
																}

																if (cursor
																		.getCount() > 0) {

																	String title_cal = cursor
																			.getString(cursor
																					.getColumnIndex("title"));

																	if (title_cal
																			.equals(title)) {
																		// Toast.makeText(act_context,
																		// "Already Added to Calender..",
																		// Toast.LENGTH_SHORT).show();
																	} else {
																		Log.i("suraj",
																				"Add to calendar = "
																						+ title);

																		addToCalendar_ifollow(
																				act,
																				title,
																				Desc,
																				start_date_mili,
																				end,
																				event_color);
																	}
																} else {

																	Log.i("suraj",
																			"Add to calendar = "
																					+ title);

																	addToCalendar_ifollow(
																			act,
																			title,
																			Desc,
																			start_date_mili,
																			end,
																			event_color);
																	// Toast.makeText(act_context,
																	// "Added to Calender..",
																	// Toast.LENGTH_SHORT).show();

																}
															} catch (Exception e) {
																e.printStackTrace();
															}
														}
														// ////////

													} else {
														if (new_champ
																.equals(cs_name_new
																		.toUpperCase()) == true) {
															if (new_game
																	.equals(champ_obj
																			.getString(
																					"ss_game_text")
																			.toUpperCase()) == true) {
																if (new_date
																		.equals(mydate11) == true) {
																	i_follow_champ_data = i_follow_champ_data
																			+ "!"
																			+ "time,"
																			+ mytime_cs;

																} else {
																	new_date = mydate11;
																	new_game = champ_obj
																			.getString(
																					"ss_game_text")
																			.toUpperCase();

																	i_follow_champ_data = i_follow_champ_data
																			+ "!"
																			+ "date,"
																			+ mydate11
																			+ "!"
																			+ "time,"
																			+ mytime_cs;

																	if (a == champ_jsonobject
																			.size() - 1) {

																		// Log.w("abc",
																		// "i_follow_champ_data = last item");
																		String video_info = null;

																		if (!temp_video_champ_List
																				.contains(cs_code_new
																						+ ":"
																						+ sport_code)) {
																			video_info = cs_code_new
																					+ ":"
																					+ sport_code;
																			temp_video_champ_List
																					.add(cs_code_new
																							+ ":"
																							+ sport_code);
																		} else {
																			video_info = null;
																		}

																		new_follow_match
																				.add(new new_ifollow_player(
																						null,
																						i_follow_champ_data,
																						team_sport_ifollow_new,
																						video_info,
																						chmp_count));

																		// new_follow_match.add(new
																		// new_ifollow_player(null,i_follow_champ_data,
																		// team_sport_ifollow_new,chmp_count));

																	}

																}
															} else {

																// MainActivity.new_follow_match.add(new
																// new_ifollow_player(null,i_follow_champ_data,team_sport_ifollow_new,chmp_count));

																i_follow_champ_data = i_follow_champ_data
																		+ ";"
																		+ ticket_url
																		+ ","
																		+ "match!"
																		+ champ_obj
																				.getString(
																						"ss_game_text")
																				.toUpperCase()
																		+ "!channel,"
																		+ channel_code1_new
																		+ ":"
																		+ channel_code2_new
																		+ ":"
																		+ channel_code3_new
																		+ "!"
																		+ mydate1
																		+ "!"
																		+ "date,"
																		+ mydate11
																		+ "!"
																		+ "time,"
																		+ mytime_cs;

																new_champ = champ_obj
																		.getString(
																				"ss_cs_name")
																		.toUpperCase();
																new_game = champ_obj
																		.getString(
																				"ss_game_text")
																		.toUpperCase();
																new_date = mydate11;

																// ///////////
																// calendar

																dataAdapter
																		.open();
																String calal = dataAdapter
																		.getcalValue();
																dataAdapter
																		.close();

																if (calal
																		.equals("Y")) {

																	Long start_date_mili = null;

																	String title = champ_obj
																			.getString(
																					"ss_game_text")
																			.toUpperCase()
																			+ " - "
																			+ cs_name_new;
																	String Desc = "SPORTIZZA";
																	String event_color = "Color.GREEN";

																	SimpleDateFormat dateFormat11i = new SimpleDateFormat(
																			"dd-MM-yyyy hh:mm a");

																	String date_addi = null;
																	Date date11i = null;

																	try {
																		date11i = dateFormat11i
																				.parse(mydate1);
																	} catch (ParseException e) {
																		e.printStackTrace();
																	}

																	SimpleDateFormat dateFormat_day_ifollow = new SimpleDateFormat(
																			"dd-MM-yyyy");

																	date_addi = dateFormat_day_ifollow
																			.format(date11i);

																	try {
																		String string1 = date_addi
																				+ " 12:00 AM";
																		Date time1 = new SimpleDateFormat(
																				"dd-MM-yyyy hh:mm a")
																				.parse(string1);
																		Calendar calendar1 = Calendar
																				.getInstance();
																		calendar1
																				.setTime(time1);

																		String string2 = date_addi
																				+ " 06:00 AM";
																		Date time2 = new SimpleDateFormat(
																				"dd-MM-yyyy hh:mm a")
																				.parse(string2);
																		Calendar calendar2 = Calendar
																				.getInstance();
																		calendar2
																				.setTime(time2);
																		// calendar2.add(Calendar.DATE,
																		// 1);

																		Date d = new SimpleDateFormat(
																				"dd-MM-yyyy hh:mm a")
																				.parse(mydate1);
																		Calendar calendar3 = Calendar
																				.getInstance();
																		calendar3
																				.setTime(d);
																		// calendar3.add(Calendar.DATE,
																		// 1);

																		Date x = calendar3
																				.getTime();

																		if (x.after(calendar1
																				.getTime())
																				&& x.before(calendar2
																						.getTime())) {
																			// checkes
																			// whether
																			// the
																			// current
																			// time
																			// is
																			// between
																			// 12.00
																			// and
																			// 6.00.
																			Log.i("suraj",
																					"Between Time");

																			String sample_date = date_addi
																					+ " 10:00 PM";
																			Date time3 = new SimpleDateFormat(
																					"dd-MM-yyyy hh:mm a")
																					.parse(sample_date);
																			Calendar calendar4 = Calendar
																					.getInstance();
																			calendar4
																					.setTime(time3);
																			calendar4
																					.add(Calendar.DATE,
																							-1);

																			start_date_mili = calendar4
																					.getTimeInMillis();

																			// Calendar
																			// cal1=Calendar.getInstance();
																			// cal1.setTimeInMillis(start_date_mili);

																			title = title
																					+ " Start at "
																					+ mydate1
																					+ "";
																		} else {
																			Log.i("suraj",
																					"Not Between Time");

																			Log.d("suraj",
																					"CAL DATE = "
																							+ d);

																			start_date_mili = d
																					.getTime();

																		}

																		long begin = start_date_mili;
																		long end = start_date_mili + 30 * 60 * 1000;// ending
																													// time
																													// in
																													// milliseconds

																		String[] proj = new String[] {
																				Instances._ID,
																				Instances.BEGIN,
																				Instances.END,
																				Instances.EVENT_ID };

																		Cursor cursor;

																		if (Integer
																				.parseInt(android.os.Build.VERSION.SDK) <= 10) {
																			ContentResolver cr = act
																					.getContentResolver();

																			cursor = cr
																					.query(Uri
																							.parse("content://calendar/calendars"),
																							proj,
																							null,
																							null,
																							null);

																			cursor.moveToFirst();
																		} else {
																			cursor = Instances
																					.query(act
																							.getContentResolver(),
																							proj,
																							begin,
																							end);

																			cursor.moveToFirst();
																		}

																		if (cursor
																				.getCount() > 0) {

																			String title_cal = cursor
																					.getString(cursor
																							.getColumnIndex("title"));

																			if (title_cal
																					.equals(title)) {
																				// Toast.makeText(act_context,
																				// "Already Added to Calender..",
																				// Toast.LENGTH_SHORT).show();
																			} else {
																				Log.i("suraj",
																						"Add to calendar = "
																								+ title);

																				addToCalendar_ifollow(
																						act,
																						title,
																						Desc,
																						start_date_mili,
																						end,
																						event_color);
																			}
																		} else {

																			Log.i("suraj",
																					"Add to calendar = "
																							+ title);

																			addToCalendar_ifollow(
																					act,
																					title,
																					Desc,
																					start_date_mili,
																					end,
																					event_color);
																			// Toast.makeText(act_context,
																			// "Added to Calender..",
																			// Toast.LENGTH_SHORT).show();

																		}
																	} catch (Exception e) {
																		e.printStackTrace();
																	}
																}
																// /////////////////////
																// chmp_count=0;
																chmp_count++;
															}
														} else {

															Log.w("abc",
																	"i_follow_champ_data = "
																			+ i_follow_champ_data);

															new_follow_match
																	.add(new new_ifollow_player(
																			null,
																			i_follow_champ_data,
																			team_sport_ifollow_new,
																			null,
																			chmp_count));

															i_follow_champ_data = cs_code_new
																	+ ";"
																	+ cs_name_new
																			.toUpperCase()
																	+ ";"
																	+ sport_name_new
																	+ ";"
																	+ sport_code
																	+ ";"
																	+ ticket_url
																	+ ","
																	+ "match!"
																	+ champ_obj
																			.getString(
																					"ss_game_text")
																			.toUpperCase()
																	+ "!channel,"
																	+ channel_code1_new
																	+ ":"
																	+ channel_code2_new
																	+ ":"
																	+ channel_code3_new
																	+ "!"
																	+ mydate1
																	+ "!"
																	+ "date,"
																	+ mydate11
																	+ "!"
																	+ "time,"
																	+ mytime_cs;

															new_champ = champ_obj
																	.getString(
																			"ss_cs_name")
																	.toUpperCase();
															new_game = champ_obj
																	.getString(
																			"ss_game_text")
																	.toUpperCase();
															new_date = mydate11;

															// ////////////calendar//////////////

															dataAdapter.open();
															String calal = dataAdapter
																	.getcalValue();
															dataAdapter.close();

															if (calal
																	.equals("Y")) {

																Long start_date_mili = null;

																String title = champ_obj
																		.getString(
																				"ss_game_text")
																		.toUpperCase()
																		+ " - "
																		+ cs_name_new;
																String Desc = "SPORTIZZA";
																String event_color = "Color.GREEN";

																SimpleDateFormat dateFormat11i = new SimpleDateFormat(
																		"dd-MM-yyyy hh:mm a");

																String date_addi = null;
																Date date11i = null;

																try {
																	date11i = dateFormat11i
																			.parse(mydate1);
																} catch (ParseException e) {
																	e.printStackTrace();
																}

																SimpleDateFormat dateFormat_day_ifollow = new SimpleDateFormat(
																		"dd-MM-yyyy");

																date_addi = dateFormat_day_ifollow
																		.format(date11i);

																try {
																	String string1 = date_addi
																			+ " 12:00 AM";
																	Date time1 = new SimpleDateFormat(
																			"dd-MM-yyyy hh:mm a")
																			.parse(string1);
																	Calendar calendar1 = Calendar
																			.getInstance();
																	calendar1
																			.setTime(time1);

																	String string2 = date_addi
																			+ " 06:00 AM";
																	Date time2 = new SimpleDateFormat(
																			"dd-MM-yyyy hh:mm a")
																			.parse(string2);
																	Calendar calendar2 = Calendar
																			.getInstance();
																	calendar2
																			.setTime(time2);
																	// calendar2.add(Calendar.DATE,
																	// 1);

																	Date d = new SimpleDateFormat(
																			"dd-MM-yyyy hh:mm a")
																			.parse(mydate1);
																	Calendar calendar3 = Calendar
																			.getInstance();
																	calendar3
																			.setTime(d);
																	// calendar3.add(Calendar.DATE,
																	// 1);

																	Date x = calendar3
																			.getTime();

																	if (x.after(calendar1
																			.getTime())
																			&& x.before(calendar2
																					.getTime())) {
																		// checkes
																		// whether
																		// the
																		// current
																		// time
																		// is
																		// between
																		// 12.00
																		// and
																		// 6.00.
																		Log.i("suraj",
																				"Between Time");

																		String sample_date = date_addi
																				+ " 10:00 PM";
																		Date time3 = new SimpleDateFormat(
																				"dd-MM-yyyy hh:mm a")
																				.parse(sample_date);
																		Calendar calendar4 = Calendar
																				.getInstance();
																		calendar4
																				.setTime(time3);
																		calendar4
																				.add(Calendar.DATE,
																						-1);

																		start_date_mili = calendar4
																				.getTimeInMillis();

																		// Calendar
																		// cal1=Calendar.getInstance();
																		// cal1.setTimeInMillis(start_date_mili);

																		title = title
																				+ " Start at "
																				+ mydate1
																				+ "";
																	} else {
																		Log.i("suraj",
																				"Not Between Time");

																		Log.d("suraj",
																				"CAL DATE = "
																						+ d);

																		start_date_mili = d
																				.getTime();

																	}

																	long begin = start_date_mili;
																	long end = start_date_mili + 30 * 60 * 1000;// ending
																												// time
																												// in
																												// milliseconds

																	String[] proj = new String[] {
																			Instances._ID,
																			Instances.BEGIN,
																			Instances.END,
																			Instances.EVENT_ID };

																	Cursor cursor;

																	if (Integer
																			.parseInt(android.os.Build.VERSION.SDK) <= 10) {
																		ContentResolver cr = act
																				.getContentResolver();

																		cursor = cr
																				.query(Uri
																						.parse("content://calendar/calendars"),
																						proj,
																						null,
																						null,
																						null);

																		cursor.moveToFirst();
																	} else {
																		cursor = Instances
																				.query(act
																						.getContentResolver(),
																						proj,
																						begin,
																						end);

																		cursor.moveToFirst();
																	}

																	if (cursor
																			.getCount() > 0) {

																		String title_cal = cursor
																				.getString(cursor
																						.getColumnIndex("title"));

																		if (title_cal
																				.equals(title)) {
																		} else {
																			Log.i("suraj",
																					"Add to calendar = "
																							+ title);

																			addToCalendar_ifollow(
																					act,
																					title,
																					Desc,
																					start_date_mili,
																					end,
																					event_color);
																		}
																	} else {

																		Log.i("suraj",
																				"Add to calendar = "
																						+ title);

																		addToCalendar_ifollow(
																				act,
																				title,
																				Desc,
																				start_date_mili,
																				end,
																				event_color);

																	}
																} catch (Exception e) {
																	e.printStackTrace();
																}
															}
															// /////////////////
															chmp_count = 0;
															chmp_count++;
															if (a == champ_jsonobject
																	.size() - 1) {

																String video_info = null;

																if (!temp_video_champ_List
																		.contains(cs_code_new
																				+ ":"
																				+ sport_code)) {
																	video_info = cs_code_new
																			+ ":"
																			+ sport_code;
																	temp_video_champ_List
																			.add(cs_code_new
																					+ ":"
																					+ sport_code);
																} else {
																	video_info = null;
																}

																new_follow_match
																		.add(new new_ifollow_player(
																				null,
																				i_follow_champ_data,
																				team_sport_ifollow_new,
																				video_info,
																				chmp_count));
															}
														}
													}
												}
											} catch (Exception e) {
												// TODO: handle exception
											}

											upcoming.setBackgroundDrawable(getResources()
													.getDrawable(
															R.drawable.tab_button));
											upcoming.setCompoundDrawablesWithIntrinsicBounds(
													0, 0,
													R.drawable.arrow_yellow, 0);
											upcoming.setTextColor(Color
													.parseColor("#FFCC11"));

											i_follow.setBackgroundDrawable(getResources()
													.getDrawable(
															R.drawable.tab_button1));
											i_follow.setCompoundDrawablesWithIntrinsicBounds(
													0, 0,
													R.drawable.arrow_black_r, 0);
											i_follow.setTextColor(Color.BLACK);

											all_sport
													.setBackgroundDrawable(getResources()
															.getDrawable(
																	R.drawable.tab_button));
											all_sport
													.setCompoundDrawablesWithIntrinsicBounds(
															0,
															0,
															R.drawable.arrow_yellow,
															0);
											all_sport.setTextColor(Color
													.parseColor("#FFCC11"));

											Log.d("suraj", " = "
													+ new_follow_match.size());

											playerAdaptersize = 1;
											if (new_follow_match.size() > 0) {

												Log.d("suraj",
														"champ_list follow not null main");
												// lv.setAdapter(pladpt);
												// pladpt.notifyDataSetChanged();
												// lv.invalidate();

											} else {

												final Custom_dialog_class custom_dialog = new Custom_dialog_class(
														MainActivity.this,
														null, true, null, false);
												custom_dialog.show();
												//
												action_progress
														.setVisibility(View.VISIBLE);

												upcoming();

												final Timer t = new Timer();
												t.schedule(new TimerTask() {
													public void run() {
														custom_dialog.dismiss();

														t.cancel();
													}
												}, 3000);

												action_progress
														.setVisibility(View.GONE);
											}

											// action_progress.setVisibility(View.GONE);

											if (get_sport_follow != null
													&& get_sport_follow
															.getCount() > 0) {
												// int cursor_count=0;
												get_sport_follow.moveToFirst();

												do {
													sport_list = get_sport_follow
															.getString(get_sport_follow
																	.getColumnIndex("player_id"));
													sport = get_sport_follow
															.getString(get_sport_follow
																	.getColumnIndex("sport"));

													new_follow_match
															.add(new new_ifollow_player(
																	null,
																	null,
																	null,
																	sport_list
																			+ ":"
																			+ sport,
																	0));

												} while (get_sport_follow
														.moveToNext());

											}

										}
									}

									@SuppressWarnings("deprecation")
									@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
									@SuppressLint("NewApi")
									private void addToCalendar_ifollow(
											Context ctx, String title,
											String Desc, Long start_date_mili,
											long end_date_mili,
											String event_color) {

										Uri eventsUri, reminderuri;

										if (Integer
												.parseInt(android.os.Build.VERSION.SDK) >= 14) {
											eventsUri = Uri
													.parse("content://com.android.calendar/events");
											reminderuri = Uri
													.parse("content://com.android.calendar/reminders");

											ContentValues event = new ContentValues();

											event.put(Events.CALENDAR_ID, 1);
											event.put(Events.TITLE, title);
											event.put(Events.DESCRIPTION, Desc);
											event.put(Events.DTSTART,
													start_date_mili);
											event.put(Events.DTEND,
													end_date_mili);
											event.put(Events.STATUS, 1);
											event.put(Events.EVENT_COLOR,
													event_color);

											event.put(Events.HAS_ALARM, 1);
											event.put(
													CalendarContract.Events.EVENT_TIMEZONE,
													TimeZone.getDefault()
															.getID());

											Log.v("suraj", "Event ="
													+ TimeZone.getDefault()
															.getID());

											Uri uri = ctx
													.getContentResolver()
													.insert(CalendarContract.Events.CONTENT_URI,
															event);

											long eventID = Long.parseLong(uri
													.getLastPathSegment());

											ContentValues reminders = new ContentValues();
											reminders.put(Reminders.EVENT_ID,
													eventID);
											reminders.put(Reminders.METHOD,
													Reminders.METHOD_ALERT);
											reminders
													.put(Reminders.MINUTES, 15);

											ctx.getContentResolver()
													.insert(CalendarContract.Reminders.CONTENT_URI,
															reminders);

											Log.v("suraj", "Reminder ="
													+ reminders);

										} else if (Integer
												.parseInt(android.os.Build.VERSION.SDK) >= 8
												&& Integer
														.parseInt(android.os.Build.VERSION.SDK) < 14) {
											eventsUri = Uri
													.parse("content://com.android.calendar/events");
											reminderuri = Uri
													.parse("content://com.android.calendar/reminders");

											ContentValues event = new ContentValues();

											event.put(Events.CALENDAR_ID, 1);
											event.put(Events.TITLE, title);
											event.put(Events.DESCRIPTION, Desc);
											event.put(Events.DTSTART,
													start_date_mili);
											event.put(Events.DTEND,
													end_date_mili);
											event.put(Events.STATUS, 1);
											event.put(Events.HAS_ALARM, 1);
											event.put(
													CalendarContract.Events.EVENT_TIMEZONE,
													TimeZone.getDefault()
															.getID());

											Log.v("suraj", "Event ="
													+ TimeZone.getDefault()
															.getID());

											Uri uri = ctx.getContentResolver()
													.insert(eventsUri, event);

											long eventID = Long.parseLong(uri
													.getLastPathSegment());

											ContentValues reminders = new ContentValues();
											reminders.put(Reminders.EVENT_ID,
													eventID);
											reminders.put(Reminders.METHOD,
													Reminders.METHOD_ALERT);
											reminders
													.put(Reminders.MINUTES, 15);

											ctx.getContentResolver().insert(
													reminderuri, reminders);

											Log.v("suraj", "Reminder ="
													+ reminders);
										}

									}

								});
							}
						}).start();

						return null;

					}
				};
				wait.execute();

			}
		});

		lv.setOnTouchListener(null);
		lv.setOnScrollListener(null);

		search_text.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> adapter, View myView,
					final int position, long arg3) {

				lv.requestFocus();

				search_text.setText("");
				search_text.clearFocus();

				hideKeyboard();

				search_text.setVisibility(View.GONE);
				search_view.setVisibility(View.VISIBLE);
				action_progress.setVisibility(View.GONE);
				app_logo.setVisibility(View.VISIBLE);

				findViewById(R.id.new_main_real_heading).setVisibility(
						View.GONE);
				findViewById(R.id.new_web_btn_head).setVisibility(View.GONE);
				findViewById(R.id.new_hori_btn_head).setVisibility(View.GONE);
				findViewById(R.id.new_video_bar).setVisibility(View.GONE);

				webView1.setVisibility(View.GONE);

				AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

					@Override
					protected void onPostExecute(Void result) {
						// TODO Auto-generated method stub
						super.onPostExecute(result);
						action_progress.setVisibility(View.GONE);

					}

					@Override
					protected void onPreExecute() {
						action_progress.setVisibility(View.VISIBLE);
						super.onPreExecute();
					}

					@Override
					protected Void doInBackground(Void... params) {

						runOnUiThread(new Runnable() {

							@Override
							public void run() {

								try {
									Thread.sleep(2000);
								} catch (InterruptedException e) {
									e.printStackTrace();
								}

								// Log.w("suraj", " click on= "+position);

								String all_data = MainActivity.result_main
										.get(position);

								Log.w("suraj", "str=" + all_data);

								String[] items = all_data.split(":");

								lv.setEmptyView(null);

								PlayerAdapter1 player_adp11 = new PlayerAdapter1(
										new PlayerData(MainActivity.this,
												items[0], country_code,
												items[1], null, null, items[3],
												null, null, null, null, null,
												false, false, true, tablet,
												null, null, null, false)
												.getPlayers());

								if (playerAdaptersize == 0) {
									search_text.setText("");
									return;

								} else {
									// search_text.clearFocus();
									adView.setVisibility(View.VISIBLE);
									upcoming.setBackgroundDrawable(getResources()
											.getDrawable(R.drawable.tab_button));
									upcoming.setCompoundDrawablesWithIntrinsicBounds(
											0, 0, R.drawable.arrow_yellow, 0);
									upcoming.setTextColor(Color
											.parseColor("#FFCC11"));

									i_follow.setBackgroundDrawable(getResources()
											.getDrawable(R.drawable.tab_button));
									i_follow.setCompoundDrawablesWithIntrinsicBounds(
											0, 0, R.drawable.arrow_yellow, 0);
									i_follow.setTextColor(Color
											.parseColor("#FFCC11"));

									all_sport
											.setBackgroundDrawable(getResources()
													.getDrawable(
															R.drawable.tab_button));
									all_sport
											.setCompoundDrawablesWithIntrinsicBounds(
													0, 0,
													R.drawable.arrow_yellow, 0);
									all_sport.setTextColor(Color
											.parseColor("#FFCC11"));

									lv.setAdapter(player_adp11);

									player_adp11.notifyDataSetChanged();

								}
							}
						});

						return null;
					}
				};
				wait.execute();
			}

		});
	}

	private void first_page_load() {

	}

	protected void Main_menu() {

		final String[] data = { "SPORTS", "NEWS", "VIDEOS", "SETTINGS" };

		LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
				.getSystemService(LAYOUT_INFLATER_SERVICE);
		View popupView = layoutInflater.inflate(R.layout.option_popup_main,
				null);
		popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT, true);

		popupWindow.setOutsideTouchable(true);
		LinearLayout rr = (LinearLayout) popupView.findViewById(R.id.op_li);
		rr.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View arg0, MotionEvent arg1) {

				popupWindow.dismiss();

				return false;
			}
		});

		ListView listView = (ListView) popupView.findViewById(R.id.listView1);

		listView.setAdapter(new MainMenu(getApplicationContext(), data));

		listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

			@SuppressWarnings("deprecation")
			public void onItemClick(AdapterView<?> parent, View v,
					int position, long id) {
				// TODO Auto-generated method stub
				System.out.println("Item Clicked");
				// Toast.makeText(getApplicationContext(),
				// "Click on=" + data[position], Toast.LENGTH_LONG).show();

				TextView t = (TextView) v.findViewById(R.id.Menu_name);

				t.setTextColor(Color.BLACK);

				ImageView ii = (ImageView) v.findViewById(R.id.image_menu);

				int color1 = Color.parseColor("#000000"); // The color u want

				ii.setColorFilter(color1);

				v.setBackgroundColor(Color.parseColor("#FFCC11"));
				popupWindow.dismiss();

				if (data[position].equals("SPORTS")) {

					try {

						webView1.setVisibility(View.GONE);
						app_logo.setVisibility(View.VISIBLE);
						actionbar_title.setVisibility(View.INVISIBLE);

						LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
								.getSystemService(LAYOUT_INFLATER_SERVICE);
						View popupView = layoutInflater.inflate(
								R.layout.sub_option_popup_main, null);
						popupWindow = new PopupWindow(popupView,
								LayoutParams.WRAP_CONTENT,
								LayoutParams.WRAP_CONTENT, true);

						popupWindow.setOutsideTouchable(true);
						//
						LinearLayout rr = (LinearLayout) popupView
								.findViewById(R.id.sub_op_li);
						rr.setOnTouchListener(new OnTouchListener() {

							@Override
							public boolean onTouch(View arg0, MotionEvent arg1) {

								popupWindow.dismiss();

								return false;
							}
						});

						ImageView title_image = (ImageView) popupView
								.findViewById(R.id.image_menu);
						final ListView listView = (ListView) popupView
								.findViewById(R.id.sub_listView1);

						listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

						title_image.setImageResource(R.drawable.sports);
						TextView sub_menu_title = (TextView) popupView
								.findViewById(R.id.sub_menu_title);
						sub_menu_title.setText("SPORTS");

						sub_menu_title.setTypeface(sport_font);
						// Typeface sport_font =
						// Typeface.createFromAsset(context.getAssets(),
						// "hel57.ttf");
						// sub_menu_title.setTypeface(sport_font);

						int bl = Color.parseColor("#000000"); // The color u
																// want
						title_image.setColorFilter(bl);

						final List<sports> data_sub = new ArrayList<sports>();
						final List<String> data_sport = new ArrayList<String>();
						// listView.setAdapter(new
						// ArrayAdapter<String>(getApplicationContext(),
						// android.R.layout.simple_list_item_1,data));
						final SubMenu_sport menu_adapter = new SubMenu_sport(
								getApplicationContext(), data_sub, data_sport);
						listView.setAdapter(menu_adapter);

						AsyncTask<Void, Void, Void> wait1 = new AsyncTask<Void, Void, Void>() {

							@Override
							protected void onPostExecute(Void result) {
								// TODO Auto-generated method stub
								super.onPostExecute(result);
								pd.dismiss();

								menu_adapter.notifyDataSetChanged();
							}

							@Override
							protected void onPreExecute() {
								pd = ProgressDialog.show(context, "",
										"Loading...", true);

								super.onPreExecute();
							}

							@Override
							protected Void doInBackground(Void... params) {
								try {
									dataAdapter.open();
									final Cursor get_sport_follow = dataAdapter
											.getsportfollow();
									startManagingCursor(get_sport_follow);

									if (get_sport_follow.getCount() > 0
											&& get_sport_follow != null) {
										get_sport_follow.moveToFirst();
										String sport_lt = "";
										String sport = "";
										do {
											sport_lt = get_sport_follow.getString(get_sport_follow
													.getColumnIndex("player_id"));

											sport = get_sport_follow.getString(get_sport_follow
													.getColumnIndex("sport"));

											data_sport.add(sport);

										} while (get_sport_follow.moveToNext());
									}
									get_sport_follow.close();

									String sportjson = Utils
											.readJsonFeed(
													"http://sportizza.com/interface/ios_sport_list.php",
													MainActivity.this);

									if (sportjson != null
											|| !sportjson.equals("null")) {
										JSONArray array_sports = null;

										array_sports = new JSONArray(sportjson);

										int array_len1 = array_sports.length();

										dataAdapter.open();
										dataAdapter.deleteSportdata();
										dataAdapter.close();

										for (int i = 0; i < array_len1; i++) {

											JSONObject JsonObject_sport = array_sports
													.getJSONObject(i);

											String ss_sport = JsonObject_sport
													.getString("ss_sport");
											String ss_sport_code = JsonObject_sport
													.getString("ss_sport_code");
											String ss_team_sport = JsonObject_sport
													.getString("ss_team_sport");

											sports s = new sports();
											s.setCode(ss_sport_code);
											s.setName(ss_sport);

											data_sub.add(s);

											dataAdapter.open();
											dataAdapter.insertSportdata(
													ss_sport, ss_sport_code,
													ss_team_sport);
											dataAdapter.close();
										}
										Log.d("suraj", "data_sub = " + data_sub);
										// lv.setAdapter(null);
										// lv.setVisibility(View.VISIBLE);

									}
								} catch (Exception e) {
									e.printStackTrace();
									// cancel(true);
									// popupWindow.dismiss();
								}

								return null;
							}
						};
						wait1.execute();

						listView.setOnItemClickListener(new OnItemClickListener() {

							@Override
							public void onItemClick(AdapterView<?> parent,
									View v, int position, long id) {

								final TextView t = (TextView) v
										.findViewById(R.id.Menu_name);

								t.setTextColor(Color.BLACK);

								ImageView ii = (ImageView) v
										.findViewById(R.id.image_menu);

								int color1 = Color.parseColor("#FFCC11"); // The
																			// color
																			// u
																			// want
								ii.setColorFilter(color1);

								v.setBackgroundColor(color1);

								popupWindow.dismiss();

								br_sport_name = t.getText().toString();

								menu_sport_cs();
							}

						});
					} catch (Exception e) {
						e.printStackTrace();
					}
					// popupWindow.setBackgroundDrawable (new BitmapDrawable());
					popupWindow.showAsDropDown(option_popup, 0, 5);
				} else if (data[position].equals("NEWS")) {
					webView1.setVisibility(View.GONE);

					app_logo.setVisibility(View.VISIBLE);
					actionbar_title.setVisibility(View.INVISIBLE);

					findViewById(R.id.new_main_real_heading).setVisibility(
							View.GONE);
					findViewById(R.id.new_web_btn_head).setVisibility(
							View.VISIBLE);
					findViewById(R.id.new_hori_btn_head).setVisibility(
							View.GONE);
					findViewById(R.id.new_video_bar).setVisibility(View.GONE);

					upcoming.setBackgroundDrawable(getResources().getDrawable(
							R.drawable.tab_button));
					upcoming.setCompoundDrawablesWithIntrinsicBounds(0, 0,
							R.drawable.arrow_yellow, 0);
					upcoming.setTextColor(Color.parseColor("#FFCC11"));

					i_follow.setBackgroundDrawable(getResources().getDrawable(
							R.drawable.tab_button));
					i_follow.setCompoundDrawablesWithIntrinsicBounds(0, 0,
							R.drawable.arrow_yellow, 0);
					i_follow.setTextColor(Color.parseColor("#FFCC11"));

					all_sport.setBackgroundDrawable(getResources().getDrawable(
							R.drawable.tab_button));
					all_sport.setCompoundDrawablesWithIntrinsicBounds(0, 0,
							R.drawable.arrow_yellow, 0);
					all_sport.setTextColor(Color.parseColor("#FFCC11"));

					pd = ProgressDialog.show(context, "", "Loading...", true);
					dataAdapter.close();
					dataAdapter.open();

					String news_lang = dataAdapter.getnews_lang();

					dataAdapter.close();

					Thread t_news = new Thread(new Runnable() {
						public void run() {

							try {

								Thread.sleep(4000);
							} catch (InterruptedException e) {
								e.printStackTrace();
							}
							runOnUiThread(new Runnable() {
								public void run() {

									lv.setVisibility(View.INVISIBLE);

									webView1.getSettings()
											.setJavaScriptEnabled(true);
									webView1.getSettings()
											.setLoadWithOverviewMode(true);
									webView1.getSettings().setUseWideViewPort(
											true);

									webView1.setWebViewClient(new WebViewClient() {

										@Override
										public void onPageFinished(
												WebView view, String url) {
											super.onPageFinished(view, url);
											webView1.setVisibility(View.VISIBLE);
										}

										@Override
										public boolean shouldOverrideUrlLoading(
												WebView view, String url) {

											view.loadUrl(url);

											return true;
										}

									});

									// Log.d("suraj","url_word = "+cs_name_url);

									webView1.loadUrl("https://news.google.com/news/i/section?pz=1&cf=all&topic=s&ned=en");
								}
							});
							pd.dismiss();
						}
					});

					t_news.start();

					Button web_b = (Button) findViewById(R.id.web_back);
					Button web_f = (Button) findViewById(R.id.web_forward);
					web_b.setTypeface(sport_font);
					web_f.setTypeface(sport_font);

					findViewById(R.id.web_back).setOnClickListener(
							new OnClickListener() {

								@Override
								public void onClick(View arg0) {

									if (webView1.canGoBack()) {
										webView1.goBack();
									}
								}
							});

					findViewById(R.id.web_forward).setOnClickListener(
							new OnClickListener() {

								@Override
								public void onClick(View v) {

									if (webView1.canGoForward()) {
										webView1.goForward();
									}
								}
							});

				} else if (data[position].equals("SETTINGS")) {

					Intent i = new Intent(MainActivity.this, Setting_Act.class);
					startActivity(i);

				}
				// else if (data[position].equals("STATISTICS")) {
				// webView1.setVisibility(View.GONE);
				// app_logo.setVisibility(View.VISIBLE);
				// actionbar_title.setVisibility(View.INVISIBLE);
				//
				// findViewById(R.id.new_main_real_heading).setVisibility(
				// View.GONE);
				// findViewById(R.id.new_web_btn_head)
				// .setVisibility(View.GONE);
				// findViewById(R.id.new_hori_btn_head).setVisibility(
				// View.GONE);
				// findViewById(R.id.new_video_bar).setVisibility(View.GONE);
				//
				// LayoutInflater layoutInflater = (LayoutInflater)
				// getBaseContext()
				// .getSystemService(LAYOUT_INFLATER_SERVICE);
				// View popupView = layoutInflater.inflate(
				// R.layout.option_popup_main, null);
				// popupWindow = new PopupWindow(popupView,
				// LayoutParams.WRAP_CONTENT,
				// LayoutParams.WRAP_CONTENT, true);
				//
				// popupWindow.setOutsideTouchable(true);
				//
				// LinearLayout rr = (LinearLayout) popupView
				// .findViewById(R.id.op_li);
				// rr.setOnTouchListener(new OnTouchListener() {
				//
				// @Override
				// public boolean onTouch(View arg0, MotionEvent arg1) {
				//
				// popupWindow.dismiss();
				//
				// return false;
				// }
				// });
				//
				// final HashMap<String, String> Hash_Stat_standing_urls = new
				// HashMap<String, String>();
				//
				// ListView listView = (ListView) popupView
				// .findViewById(R.id.listView1);
				//
				// final List<String> data_sub_stat = new ArrayList<String>();
				// // listView.setAdapter(new
				// // ArrayAdapter<String>(getApplicationContext(),
				// // android.R.layout.simple_list_item_1,data));
				// final SubMenu_stat menu_adapter_stat = new SubMenu_stat(
				// getApplicationContext(), data_sub_stat);
				// listView.setAdapter(menu_adapter_stat);
				//
				// AsyncTask<Void, Void, Void> wait1 = new AsyncTask<Void, Void,
				// Void>() {
				//
				// @Override
				// protected void onPostExecute(Void result) {
				// // TODO Auto-generated method stub
				// super.onPostExecute(result);
				// pd.dismiss();
				//
				// menu_adapter_stat.notifyDataSetChanged();
				// }
				//
				// @Override
				// protected void onPreExecute() {
				// pd = ProgressDialog.show(context, "", "Loading...",
				// true);
				// super.onPreExecute();
				// }
				//
				// @Override
				// protected Void doInBackground(Void... params) {
				//
				// try {
				// String sportjson_stat = Utils
				// .readJsonFeed(
				// "http://sportizza.com/interface/ios_get_rankings_data.php",
				// MainActivity.this);
				//
				// String statastics = sportjson_stat.replace(
				// "\\/", "/");
				//
				// JSONArray array_stat = null;
				//
				// array_stat = new JSONArray(statastics);
				//
				// int array_len1 = array_stat.length();
				//
				// List<String> Stat_Menu_ = new ArrayList<String>();
				// List<String> Stat_standing_urls = new ArrayList<String>();
				//
				// // Hash_Stat_standing_urls=new HashMap<String,
				// // String>();
				//
				// String standing_urls_string = null, new_sport = null,
				// new_champ = null;
				//
				// for (int i = 0; i < array_len1; i++) {
				//
				// JSONObject JsonObject_stat = array_stat
				// .getJSONObject(i);
				//
				// String ss_sport_code = JsonObject_stat
				// .getString("ss_sport_code");
				// String ss_cs_code = JsonObject_stat
				// .getString("ss_cs_code");
				// String ss_cs_name = JsonObject_stat
				// .getString("ss_cs_name");
				// String ss_group = JsonObject_stat
				// .getString("ss_group");
				// String ss_standings_url = JsonObject_stat
				// .getString("ss_standings_url");
				//
				// if (ss_cs_code.equals("-1")) {
				// if (data_sub_stat
				// .contains(ss_sport_code + ":"
				// + null) == false) {
				// data_sub_stat.add(ss_sport_code
				// + ":" + null);
				// }
				//
				// } else {
				// if (data_sub_stat
				// .contains(ss_sport_code + ":"
				// + ss_cs_name) == false) {
				// data_sub_stat.add(ss_sport_code
				// + ":" + ss_cs_name);
				// }
				//
				// }
				//
				// if (standing_urls_string == null) {
				//
				// standing_urls_string = ss_group + "''"
				// + ss_standings_url;
				// new_sport = ss_sport_code;
				// new_champ = ss_cs_name;
				// } else {
				// if (new_sport.equals(ss_sport_code) == true
				// && new_champ.equals(ss_cs_name) == true) {
				//
				// standing_urls_string = standing_urls_string
				// + ";"
				// + ss_group
				// + "''"
				// + ss_standings_url;
				//
				// if (i == array_len1 - 1) {
				//
				// Hash_Stat_standing_urls.put(
				// new_sport + ":"
				// + new_champ,
				// standing_urls_string);
				// Stat_standing_urls
				// .add(standing_urls_string);
				// }
				// } else {
				//
				// Hash_Stat_standing_urls
				// .put(new_sport + ":"
				// + new_champ,
				// standing_urls_string);
				//
				// Stat_standing_urls
				// .add(standing_urls_string);
				//
				// new_sport = ss_sport_code;
				// new_champ = ss_cs_name;
				// standing_urls_string = ss_group
				// + "''" + ss_standings_url;
				//
				// }
				//
				// }
				//
				// }
				//
				// Log.v("suraj_", "Hash_Stat_standing_urls=="
				// + Hash_Stat_standing_urls);
				//
				// Log.w("suraj_", "data_sub_stat=="
				// + data_sub_stat);
				//
				// // lv.setAdapter(null);
				// // lv.setVisibility(View.VISIBLE);
				// } catch (Exception e) {
				// e.printStackTrace();
				// }
				// return null;
				// }
				// };
				// wait1.execute();
				//
				// listView.setOnItemClickListener(new OnItemClickListener() {
				//
				// @SuppressWarnings("deprecation")
				// @Override
				// public void onItemClick(AdapterView<?> parent, View v,
				// int position, long id) {
				//
				// app_logo.setVisibility(View.INVISIBLE);
				// actionbar_title.setVisibility(View.VISIBLE);
				//
				// String[] sport_n = data_sub_stat.get(position)
				// .split(":");
				// dataAdapter.open();
				//
				// actionbar_title.setText(dataAdapter
				// .getsportname(sport_n[0]));
				//
				// actionbar_title.setTypeface(sport_font);
				//
				// dataAdapter.close();
				//
				// findViewById(R.id.new_main_real_heading)
				// .setVisibility(View.GONE);
				// findViewById(R.id.new_web_btn_head).setVisibility(
				// View.GONE);
				// findViewById(R.id.new_hori_btn_head).setVisibility(
				// View.VISIBLE);
				// findViewById(R.id.new_video_bar).setVisibility(
				// View.GONE);
				//
				// upcoming.setBackgroundDrawable(getResources()
				// .getDrawable(R.drawable.tab_button));
				// upcoming.setCompoundDrawablesWithIntrinsicBounds(0,
				// 0, R.drawable.arrow_yellow, 0);
				// upcoming.setTextColor(Color.parseColor("#FFCC11"));
				//
				// i_follow.setBackgroundDrawable(getResources()
				// .getDrawable(R.drawable.tab_button));
				// i_follow.setCompoundDrawablesWithIntrinsicBounds(0,
				// 0, R.drawable.arrow_yellow, 0);
				// i_follow.setTextColor(Color.parseColor("#FFCC11"));
				//
				// all_sport.setBackgroundDrawable(getResources()
				// .getDrawable(R.drawable.tab_button));
				// all_sport.setCompoundDrawablesWithIntrinsicBounds(
				// 0, 0, R.drawable.arrow_yellow, 0);
				// all_sport.setTextColor(Color.parseColor("#FFCC11"));
				//
				// // Toast.makeText(
				// // getApplicationContext(),
				// // "Click on="
				// // + Hash_Stat_standing_urls
				// // .get(data_sub_stat
				// // .get(position)),
				// // Toast.LENGTH_LONG).show();
				//
				// String[] btn_url = Hash_Stat_standing_urls.get(
				// data_sub_stat.get(position)).split(";");
				// popupWindow.dismiss();
				//
				// lv.setAdapter(null);
				//
				// HorizontalScrollView scrollView = (HorizontalScrollView)
				// findViewById(R.id.horizontalScrollView1);
				//
				// final LinearLayout linearLayout = (LinearLayout)
				// findViewById(R.id.hori_lin);
				//
				// ImageView stat_img = (ImageView) findViewById(R.id.stat_img);
				//
				// try {
				//
				// InputStream ims = getAssets().open(
				// "sports/" + sport_n[0] + ".png");
				// Drawable d = Drawable.createFromStream(ims,
				// null);
				// stat_img.setImageDrawable(d);// (getResources().getb)
				//
				// } catch (Exception e) {
				// e.printStackTrace();
				// }
				//
				// Typeface bfont = Typeface.createFromAsset(
				// getAssets(), "hel57.ttf");
				//
				// linearLayout.removeAllViews();
				//
				// for (int i = 0; i < btn_url.length; i++) {
				// String[] btn_txt = btn_url[i].split("''");
				// // Add Buttons
				// // Log.d("suraj_", "btn_txt=="+btn_txt[0]);
				// final Button button = new Button(
				// MainActivity.this);
				// button.setText(btn_txt[0]);
				// button.setGravity(Gravity.CENTER
				// | Gravity.CENTER_VERTICAL);
				// button.setPadding(1, 0, 1, 0);
				// button.setTextSize(11);
				// button.setLayoutParams(new LinearLayout.LayoutParams(
				// 115, LayoutParams.MATCH_PARENT, 1f));
				// button.setTextColor(Color.BLACK);
				// button.setTypeface(bfont);
				// button.setBackgroundDrawable(getResources()
				// .getDrawable(R.drawable.tab_button1));
				// button.setTag(btn_txt[1]);
				// linearLayout.addView(button);
				//
				// button.setOnClickListener(new OnClickListener() {
				//
				// @Override
				// public void onClick(View arg0) {
				//
				// webView1.setVisibility(View.VISIBLE);
				//
				// int buttonPressedResId = R.drawable.tab_button;
				// int buttonNormalResId = R.drawable.tab_button1;
				//
				// StateListDrawable states = new StateListDrawable();
				// states.addState(
				// new int[] { android.R.attr.state_pressed },
				// getResources().getDrawable(
				// buttonPressedResId));
				// states.addState(
				// new int[] { android.R.attr.state_focused },
				// getResources().getDrawable(
				// buttonPressedResId));
				// states.addState(
				// new int[] {},
				// getResources().getDrawable(
				// buttonNormalResId));
				//
				// button.setBackgroundDrawable(states);
				//
				//
				// // Toast.makeText(getApplicationContext(),
				// // "Click on=" + button.getTag(),
				// // Toast.LENGTH_LONG).show();
				// Log.d("suraj_", "button.getTag() =="
				// + button.getTag());
				//
				// // webView1.setVisibility(View.INVISIBLE);
				//
				// pd = ProgressDialog.show(context, "",
				// "Loading...", true);
				//
				// Thread t_news = new Thread(
				// new Runnable() {
				// public void run() {
				//
				// try {
				//
				// Thread.sleep(4000);
				// } catch (InterruptedException e) {
				// e.printStackTrace();
				// }
				// runOnUiThread(new Runnable() {
				// public void run() {
				//
				// // lv.setEmptyView(findViewById(R.id.progressBar1));
				//
				// lv.setVisibility(View.INVISIBLE);
				//
				//
				// webView1.getSettings()
				// .setJavaScriptEnabled(
				// true);
				// webView1.getSettings()
				// .setLoadWithOverviewMode(
				// true);
				// webView1.getSettings()
				// .setUseWideViewPort(
				// true);
				//
				// webView1.setWebViewClient(new WebViewClient() {
				//
				// @Override
				// public void onPageFinished(
				// WebView view,
				// String url) {
				// super.onPageFinished(
				// view,
				// url);
				// webView1.setVisibility(View.VISIBLE);
				// }
				//
				// @Override
				// public boolean shouldOverrideUrlLoading(
				// WebView view,
				// String url) {
				//
				// view.loadUrl(url);
				//
				// return true;
				// }
				//
				// });
				//
				// // Log.d("suraj","url_word = "+cs_name_url);
				//
				// webView1.loadUrl(button
				// .getTag()
				// .toString());
				// }
				// });
				// pd.dismiss();
				// }
				// });
				//
				// t_news.start();
				//
				// }
				// });
				// }
				//
				// }
				// });
				//
				// popupWindow.showAsDropDown(option_popup, 0, 5);
				// }
				else if (data[position].equals("VIDEOS")) {
					findViewById(R.id.new_main_real_heading).setVisibility(
							View.GONE);
					findViewById(R.id.new_web_btn_head)
							.setVisibility(View.GONE);
					findViewById(R.id.new_hori_btn_head).setVisibility(
							View.GONE);
					findViewById(R.id.new_video_bar)
							.setVisibility(View.VISIBLE);

					TextView new_v_txt = (TextView) findViewById(R.id.new_video_txt);

					new_v_txt.setTypeface(sport_font);

					webView1.setVisibility(View.GONE);

					upcoming.setBackgroundDrawable(getResources().getDrawable(
							R.drawable.tab_button));
					upcoming.setCompoundDrawablesWithIntrinsicBounds(0, 0,
							R.drawable.arrow_yellow, 0);
					upcoming.setTextColor(Color.parseColor("#FFCC11"));

					i_follow.setBackgroundDrawable(getResources().getDrawable(
							R.drawable.tab_button));
					i_follow.setCompoundDrawablesWithIntrinsicBounds(0, 0,
							R.drawable.arrow_yellow, 0);
					i_follow.setTextColor(Color.parseColor("#FFCC11"));

					all_sport.setBackgroundDrawable(getResources().getDrawable(
							R.drawable.tab_button));
					all_sport.setCompoundDrawablesWithIntrinsicBounds(0, 0,
							R.drawable.arrow_yellow, 0);
					all_sport.setTextColor(Color.parseColor("#FFCC11"));

					final ArrayList<String> entity = new ArrayList<String>();
					final ArrayList<String> playlist = new ArrayList<String>();

					final Youtube_list youtube_adp = new Youtube_list(
							MainActivity.this, entity, playlist);
					lv.setAdapter(youtube_adp);

					AsyncTask<Void, Void, Void> wait1 = new AsyncTask<Void, Void, Void>() {

						@Override
						protected void onPostExecute(Void result) {
							// TODO Auto-generated method stub
							super.onPostExecute(result);
							pd.dismiss();
							youtube_adp.notifyDataSetChanged();
						}

						@Override
						protected void onPreExecute() {
							pd = ProgressDialog.show(context, "", "Loading...",
									true);
							super.onPreExecute();
						}

						@Override
						protected Void doInBackground(Void... params) {

							dataAdapter.open();
							Cursor get_all_follow = dataAdapter
									.getfollowerlist();
							startManagingCursor(get_all_follow);
							get_all_follow.moveToFirst();

							Cursor get_champ_follow = dataAdapter
									.getchamplist();
							startManagingCursor(get_champ_follow);
							get_champ_follow.moveToFirst();

							Cursor sportfollow = dataAdapter.getsportfollow();
							sportfollow.moveToFirst();

							String sport_list_code = "";
							String pl_tm_list = "";
							String champ_list = "";

							if (get_all_follow.getCount() > 0) {
								do {
									// Log.d("suraj_","sportfollow = "+sportfollow.getString(sportfollow.getColumnIndexOrThrow("player_id")));

									pl_tm_list = pl_tm_list
											+ get_all_follow.getString(get_all_follow
													.getColumnIndexOrThrow("player_id"))
											+ ",";

								} while (get_all_follow.moveToNext());

								pl_tm_list = pl_tm_list.substring(0,
										pl_tm_list.length() - 1);

							} else {
								pl_tm_list = "-1";
							}

							if (get_champ_follow.getCount() > 0) {
								do {
									// Log.d("suraj_","sportfollow = "+sportfollow.getString(sportfollow.getColumnIndexOrThrow("player_id")));

									champ_list = champ_list
											+ get_champ_follow.getString(get_champ_follow
													.getColumnIndexOrThrow("player_id"))
											+ ",";

								} while (get_champ_follow.moveToNext());

								champ_list = champ_list.substring(0,
										champ_list.length() - 1);
							} else {
								champ_list = "-1";
							}

							if (sportfollow.getCount() > 0) {
								do {
									// Log.d("suraj_","sportfollow = "+sportfollow.getString(sportfollow.getColumnIndexOrThrow("player_id")));

									sport_list_code = sport_list_code
											+ sportfollow.getString(sportfollow
													.getColumnIndexOrThrow("player_id"))
											+ ",";

								} while (sportfollow.moveToNext());

								sport_list_code = sport_list_code.substring(0,
										sport_list_code.length() - 1);

								Log.d("suraj_", "sportfollow = "
										+ sport_list_code);

							}
							dataAdapter.close();

							try {
								String _response = Utils.readJsonFeed(
										"http://sportizza.com/interface/ios_youtube_api.php?player_code="
												+ pl_tm_list + "&champ_code="
												+ champ_list + "&sport_code="
												+ sport_list_code + "",
										MainActivity.this);

								JSONArray array_entity = null;

								array_entity = new JSONArray(_response);

								int array_len1 = array_entity.length();

								for (int i = 0; i < array_len1; i++) {

									JSONObject jsonObject1 = array_entity
											.getJSONObject(i);

									String entity_name = jsonObject1
											.getString("entity_name");
									String ss_youtube_url = jsonObject1
											.getString("ss_youtube_url");

									String play_list = ss_youtube_url
											.substring(ss_youtube_url
													.lastIndexOf("list=") + 1);

									entity.add(entity_name);
									playlist.add(play_list);
								}

								Log.i("suraj_", "playlist==" + playlist);

							} catch (Exception e1) {
								e1.printStackTrace();
							}
							return null;
						}
					};
					wait1.execute();

				}
			}

			private ListView getListView() {
				return lv;
			}
		});
		// popupWindow.setBackgroundDrawable (new BitmapDrawable());
		popupWindow.showAsDropDown(option_popup, 0, 5);

	}

	/*
	 * @SuppressWarnings("deprecation") protected void getBrowserfirst() { //
	 * search_text.clearFocus();
	 * 
	 * String[] sport_name = new String[] {
	 * "BADMINTON","BASEBALL","BASKETBALL","CRICKET","FOOTBALL","FOOTBALL USA",
	 * "FORMULA 1"
	 * ,"GOLF","HOCKEY","ICE HOCKEY","INDICAR","MOTOGP","NASCAR","RALLY"
	 * ,"RUGBY", "SQUASH","SUPERBIKE","TENNIS","UFC"};
	 * 
	 * 
	 * i_follow.setBackgroundDrawable(getResources().getDrawable(
	 * R.drawable.unselect));
	 * upcoming.setBackgroundDrawable(getResources().getDrawable(
	 * R.drawable.unselect));
	 * setting.setBackgroundDrawable(getResources().getDrawable(
	 * R.drawable.unselect));
	 * all_sport.setBackgroundDrawable(getResources().getDrawable(
	 * R.drawable.unselect));
	 * browser.setBackgroundDrawable(getResources().getDrawable(
	 * R.drawable.select));
	 * 
	 * lv.setVisibility(View.GONE); // //gridView.setVisibility(View.VISIBLE);
	 * // //gridView.setAdapter(new ImageAdapter(MainActivity.this,
	 * sport_name));
	 * 
	 * }
	 */
	/*
	 * protected ArrayList<String> getArraylist() {
	 * 
	 * return null; }
	 */

	protected void initiatePopupWindow1(String msg, int x, int y) {
		try {
			LayoutInflater inflater = (LayoutInflater) MainActivity.this
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			View layout = inflater.inflate(R.layout.popup_window,
					(ViewGroup) findViewById(R.id.popup_element));
			pwindo = new PopupWindow(layout, 350, LayoutParams.WRAP_CONTENT,
					true);
			pwindo.showAtLocation(layout, Gravity.NO_GRAVITY, x, y);
			JustifiedTextView txt_msg = (JustifiedTextView) layout
					.findViewById(R.id.txtView);

			// String htmlText = " %s ";

			txt_msg.setText("OK");

			Button btnClosePopup = (Button) layout
					.findViewById(R.id.btn_close_popup);
			btnClosePopup.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {

					pwindo.dismiss();

				}
			});

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	protected void initiatePopupWindow(String msg) {
		try {
			LayoutInflater inflater = (LayoutInflater) MainActivity.this
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			View layout = inflater.inflate(R.layout.popup_window,
					(ViewGroup) findViewById(R.id.popup_element));
			pwindo = new PopupWindow(layout, 350, LayoutParams.WRAP_CONTENT,
					true);
			pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);
			JustifiedTextView txt_msg = (JustifiedTextView) layout
					.findViewById(R.id.txtView);

			// String htmlText = " %s ";

			txt_msg.setText(msg);

			Button btnClosePopup = (Button) layout
					.findViewById(R.id.btn_close_popup);
			btnClosePopup.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {

					pwindo.dismiss();

				}
			});

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	protected void hideKeyboard() {
		// try
		// {
		// InputMethodManager inputManager = (InputMethodManager)
		// activity.getSystemService(Context.INPUT_METHOD_SERVICE);
		// inputManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
		// InputMethodManager.HIDE_NOT_ALWAYS);
		// }
		// catch (Exception e)
		// {
		// // Ignore exceptions if any
		// Log.e("KeyBoardUtil", e.toString(), e);
		// }

		InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.hideSoftInputFromWindow(search_text.getWindowToken(), 0);

		// InputMethodManager imm = (InputMethodManager)
		// getSystemService(Activity.INPUT_METHOD_SERVICE);
		// imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
	}

	protected void hideKeyboard_onback() {
		// try
		// {
		// InputMethodManager inputManager = (InputMethodManager)
		// activity.getSystemService(Context.INPUT_METHOD_SERVICE);
		// inputManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
		// InputMethodManager.HIDE_NOT_ALWAYS);
		// }
		// catch (Exception e)
		// {
		// // Ignore exceptions if any
		// Log.e("KeyBoardUtil", e.toString(), e);
		// }

		search_text.setText("");
		search_view.setVisibility(View.VISIBLE);
		search_text.setVisibility(View.GONE);
		action_progress.setVisibility(View.GONE);
		app_logo.setVisibility(View.VISIBLE);

		InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.hideSoftInputFromWindow(search_text.getWindowToken(), 0);

	}

	@Override
	protected void onPause() {
		super.onPause();
		return;
	}

	private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
		@Override
		public void onReceive(Context context, Intent intent) {
			WakeLocker.acquire(getApplicationContext());

			WakeLocker.release();
		}
	};

	@Override
	protected void onDestroy() {

		dataAdapter.close();

		if (adView != null) {
			adView.destroy();
		}

		super.onDestroy();
	}

	@Override
	protected void onResume() {
		// search_text.clearFocus();
		ll.requestFocus();
		super.onResume();
	}

	@Override
	protected void onStop() {

		super.onStop();
	}

	boolean doubleBackToExitPressedOnce = false;

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		if (keyCode == KeyEvent.KEYCODE_BACK) {
			Log.d("suraj_", "Back Press");

			hideKeyboard_onback();

			// search_text.clearFocus();
			// search_text.setText("");
			// search_view.setVisibility(View.VISIBLE);
			// search_text.setVisibility(View.GONE);
			// action_progress.setVisibility(View.GONE);
			// app_logo.setVisibility(View.VISIBLE);

			// search_text.clearFocus();
			if (search_boolean == true) {
				search_text.clearFocus();
				search_boolean = false;
				search_text.setText("");

				search_view.setVisibility(View.VISIBLE);
				search_text.setVisibility(View.GONE);
				action_progress.setVisibility(View.GONE);
				app_logo.setVisibility(View.VISIBLE);

			} else {
				if (search_text.isFocused()) {
					// search_text.clearFocus();
					search_view.setVisibility(View.VISIBLE);
					search_text.setVisibility(View.GONE);
					action_progress.setVisibility(View.GONE);
					app_logo.setVisibility(View.VISIBLE);
					// hideKeyboard();
				} else {
					AlertDialog.Builder builder = new AlertDialog.Builder(this);
					builder.setMessage("Do You Want to Close the Application")
							.setCancelable(false)
							.setPositiveButton("Yes",
									new DialogInterface.OnClickListener() {
										public void onClick(
												DialogInterface dialog, int id) {
											setResult(200);

											if (StartActivity.is_app_start == true) {
												StartActivity.first_act
														.finish();
												sport_follow_class.sport_act
														.finish();
												android.os.Process
														.killProcess(android.os.Process
																.myPid());
												finish();
											} else {
												StartActivity.first_act
														.finish();
												// sport_follow_class.sport_act
												// .finish();
												android.os.Process
														.killProcess(android.os.Process
																.myPid());
												finish();
											}

											dialog.dismiss();
										}

									})
							.setNegativeButton("No",
									new DialogInterface.OnClickListener() {
										public void onClick(
												DialogInterface dialog, int id) {
											dialog.cancel();
										}
									});
					AlertDialog alert = builder.create();
					alert.show();
					setResult(RESULT_CANCELED);
				}
			}
			return true;
		}

		return super.onKeyDown(keyCode, event);
	}

	public class PlayerAdapter1 extends BaseAdapter {

		final List<Row> rows;

		public PlayerAdapter1(final List<Player> players) {

			rows = new ArrayList<Row>();// member variable

			for (Player player : players) {

				if (player.getteam().toString().equals("N")) {

					rows.add(new PlayerRow(LayoutInflater
							.from(MainActivity.this), player, MainActivity.this));
				}
				if (player.getteam().toString().equals("Y")) {
					rows.add(new TeamRow(
							LayoutInflater.from(MainActivity.this), player,
							MainActivity.this));

				}
				if (player.getteam().toString().equals("A")
						&& player.getchamp_details() != null) {
					rows.add(new ChampRow(LayoutInflater
							.from(MainActivity.this), player, MainActivity.this));
				}
				if (player.getteam().toString().equals("A")
						&& player.getchamp_details() == null) {
					rows.add(new old_ChampRow(LayoutInflater
							.from(MainActivity.this), player, MainActivity.this));
				}
			}

		}

		@Override
		public int getViewTypeCount() {
			return Rowtype.values().length;
		}

		@Override
		public int getItemViewType(int position) {
			return rows.get(position).getViewType();
		}

		@Override
		public int getCount() {
			return rows.size();
		}

		@Override
		public Object getItem(int position) {
			return position;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View conView, ViewGroup parent) {
			return rows.get(position).getView(conView);
		}

	}

	public class PlayerAdapter extends BaseAdapter {

		final List<Row> rows;

		public PlayerAdapter(final List<Player> players) {

			rows = new ArrayList<Row>();// member variable

			Thread t = new Thread(new Runnable() {

				@Override
				public void run() {

					runOnUiThread(new Runnable() {

						@Override
						public void run() {

							// Log.d("suraj", "Player Size = "+players.size());
							// playerAdaptersize = players.size();
							if (players.size() == 0) {
								if (upcominValue != null) {
									final Custom_dialog_class custom_dialog = new Custom_dialog_class(
											MainActivity.this, null, false,
											upcominValue + " HOURS", true);
									custom_dialog.show();

									final Timer t1 = new Timer();
									t1.schedule(new TimerTask() {
										public void run() {
											custom_dialog.dismiss();
											t1.cancel();
											// return ;
										}
									}, 3000);
								}

							} else {
								for (Player player : players) {

									if (player.getteam().toString().equals("N")) {

										rows.add(new PlayerRow(LayoutInflater
												.from(MainActivity.this),
												player, MainActivity.this));
									}
									if (player.getteam().toString().equals("Y")) {
										rows.add(new TeamRow(LayoutInflater
												.from(MainActivity.this),
												player, MainActivity.this));

									}
									if (player.getteam().toString().equals("A")
											&& player.getchamp_details() != null) {
										rows.add(new ChampRow(LayoutInflater
												.from(MainActivity.this),
												player, MainActivity.this));
									}
									if (player.getteam().toString().equals("A")
											&& player.getchamp_details() == null) {
										rows.add(new old_ChampRow(
												LayoutInflater
														.from(MainActivity.this),
												player, MainActivity.this));
									}
								}
							}

						}
					});

				}
			});
			t.start();

		}

		@Override
		public int getViewTypeCount() {
			return Rowtype.values().length;
		}

		@Override
		public int getItemViewType(int position) {
			return rows.get(position).getViewType();
		}

		@Override
		public int getCount() {
			return rows.size();
		}

		@Override
		public Object getItem(int position) {
			return position;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View conView, ViewGroup parent) {
			return rows.get(position).getView(conView);
		}

	}

	public void showToast(String msg) {
		Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG).show();
	}

	private Bitmap download_Image(String url, String sport_code, String team) {

		Bitmap bm = null;

		try {
			URL aURL = new URL(url);
			URLConnection conn = aURL.openConnection();
			conn.connect();
			InputStream is = conn.getInputStream();
			BufferedInputStream bis = new BufferedInputStream(is);
			bm = BitmapFactory.decodeStream(bis);
			bis.close();
			is.close();
		} catch (IOException e) {
			Log.e("Hub", "Error getting the image from server : ");
		}
		return bm;
	}

	public static Context get_Main_Context() {
		return context;
	}

	public static String getDate_informat(String st_date) {
		String mydate = null;
		try {
			SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
			formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
			Date date = (Date) formatter.parse(st_date);

			Log.e("suraj", "DA==" + date);

			SimpleDateFormat dateFormat = new SimpleDateFormat(
					"dd-MM-yyyy HH:mm");

			dateFormat.setTimeZone(TimeZone.getDefault());

			mydate = dateFormat.format(date);

		} catch (Exception e) {
		}

		return mydate;
	}

	// ======================================================//

	// @SuppressWarnings("deprecation")
	// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
	// public void main_work() {
	//
	//
	// }

	protected void upcoming() {

		findViewById(R.id.new_main_real_heading).setVisibility(View.GONE);
		findViewById(R.id.new_web_btn_head).setVisibility(View.GONE);
		findViewById(R.id.new_hori_btn_head).setVisibility(View.GONE);
		findViewById(R.id.new_video_bar).setVisibility(View.GONE);

		webView1.setVisibility(View.GONE);

		lv.setOnTouchListener(null);
		lv.setOnScrollListener(null);

		// rel.setVisibility(View.GONE);
		// br_layout_2.setVisibility(View.GONE);

		lv.setDividerHeight(1);

		lv.setOnScrollListener(null);

		empty.setVisibility(View.INVISIBLE);

		MainActivity.this.getWindow().setSoftInputMode(
				WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

		lv.setVisibility(View.VISIBLE);

		search_text.clearFocus();

		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");

		dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

		Date date = new Date();

		final String current_date = dateFormat.format(date);

		// String number = Setting_Act.next_hr.getText().toString();

		// final String[] hour = number.split(" ");

		Log.d("suraj", "current_date = " + current_date);

		upcoming.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.tab_button1));
		upcoming.setCompoundDrawablesWithIntrinsicBounds(0, 0,
				R.drawable.arrow_black_r, 0);
		upcoming.setTextColor(Color.BLACK);

		i_follow.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.tab_button));
		i_follow.setCompoundDrawablesWithIntrinsicBounds(0, 0,
				R.drawable.arrow_yellow, 0);
		i_follow.setTextColor(Color.parseColor("#FFCC11"));

		all_sport.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.tab_button));
		all_sport.setCompoundDrawablesWithIntrinsicBounds(0, 0,
				R.drawable.arrow_yellow, 0);
		all_sport.setTextColor(Color.parseColor("#FFCC11"));

		action_progress.setVisibility(View.VISIBLE);

		new_upcoming_match = new ArrayList<new_ifollow_player>();

		final new_upcoming_adapter pladpt1 = new new_upcoming_adapter(
				MainActivity.this, new_upcoming_match, null, null, null, null);
		lv.setAdapter(pladpt1);
		// pladpt.notifyDataSetChanged();

		AsyncTask<Void, Void, String> wait = new AsyncTask<Void, Void, String>() {

			@Override
			protected void onPostExecute(String result) {
				// TODO Auto-generated method stub
				super.onPostExecute(result);
				pladpt1.notifyDataSetChanged();
				action_progress.setVisibility(View.GONE);
				// Log.d("suraj","Result Post = "+result);

				if (result.equals("zero")) {
					empty.setVisibility(View.VISIBLE);
					empty.setText("Data Not Available check back later");
					lv.setEmptyView(empty);
				}
				dataAdapter.close();
			}

			@Override
			protected void onPreExecute() {
				action_progress.setVisibility(View.VISIBLE);
				super.onPreExecute();
			}

			@Override
			protected String doInBackground(Void... params) {

				new Thread(new Runnable() {

					@Override
					public void run() {
						runOnUiThread(new Runnable() {

							@Override
							public void run() {
								AdRequest adRequest = new AdRequest();
								adRequest
										.addTestDevice(AdRequest.TEST_EMULATOR);
								adView.loadAd(adRequest);
								adView.setVisibility(View.VISIBLE);
							}
						});
					}
				}).start();

				dataAdapter.open();
				upcominValue = dataAdapter.getupcomingValue();

				String abc = "";

				// dataAdapter.open();

				String player_list1 = "";
				ArrayList<String> pl_list1 = new ArrayList<String>();

				final Cursor get_all_follow1 = dataAdapter.getfollowerlist();
				startManagingCursor(get_all_follow1);

				// int cursor_count=get_all_follow.getCount();

				// Log.v("suraj","count = "+get_all_follow.getCount());

				if (get_all_follow1 != null && get_all_follow1.getCount() > 0) {
					// int cursor_count=0;
					// Tab_img.setImageBitmap(BitmapFactory.decodeResource(
					// getResources(), R.drawable.follow_selected));

					get_all_follow1.moveToFirst();

					do {
						player_list1 = get_all_follow1
								.getString(get_all_follow1
										.getColumnIndex("player_id"))
								+ "," + player_list1;

						pl_list1.add(get_all_follow1.getString(get_all_follow1
								.getColumnIndex("player_id")));

					} while (get_all_follow1.moveToNext());

					player_list1 = player_list1.substring(0,
							player_list1.length() - 1);

					Log.v("suraj", "player_list 2 = " + player_list1);
					// allfollowphp =
					// "http://www.sportizza.com/interface/ios_all_follow.php?follow="
					// + player_list + "&follow_cs=-1";

				} else {
					Log.w("suraj", "player/team Follow Null");

					player_list1 = "-1";
				}

				String i_follow_data1 = null;
				String i_follow_champ_data1 = null, new_champ1 = null, new_game1 = null, new_date1 = null;
				String ichamp_name_temp1 = null;
				String iteam_type_temp1 = null;
				String Json_result = Utils.readJsonFeed(
						"http://sportizza.com/interface/ios_next_new.php?next_hr="
								+ upcominValue + "&dt_time=" + current_date
								+ "&iso_cd=" + country_code + "", act);

				try {

					JSONArray array_ifollow_new = new JSONArray(Json_result);

					int json_len = array_ifollow_new.length();

					// ArrayList<JSONObject> upcoming_jsonobject = new
					// ArrayList<JSONObject>();

					Log.d("suraj", "Json Upcoming len = " + json_len);

					int count = 0;
					int chmp_count = 0;
					String prev_champ = "NA";
					String prev_game = "NA";
					String prev_date = "NA";
					String prev_type = "NA";

					if (json_len == 0) {
						abc = "zero";
					}

					for (int i = 0; i < json_len; i++) {
						JSONObject JsonObject_ifollow_new = array_ifollow_new
								.getJSONObject(i);
						if (i == 0) {
							prev_champ = array_ifollow_new.getJSONObject(i)
									.getString("ss_cs_code");
						}
						if (i > 0) {
							prev_champ = array_ifollow_new.getJSONObject(i - 1)
									.getString("ss_cs_code");
						}

						String cs_code_new = JsonObject_ifollow_new
								.getString("ss_cs_code");

						String cs_name_new = JsonObject_ifollow_new.getString(
								"ss_cs_name").toUpperCase();

						String sport_name_new = JsonObject_ifollow_new
								.getString("ss_sport");

						String player_code1_new = JsonObject_ifollow_new
								.getString("ss_player_code1");
						String player_code2_new = JsonObject_ifollow_new
								.getString("ss_player_code2");
						String player_code3_new = JsonObject_ifollow_new
								.getString("ss_player_code3");
						String player_code4_new = JsonObject_ifollow_new
								.getString("ss_player_code4");

						String player1_ifollow_new = JsonObject_ifollow_new
								.getString("player1");
						String player2_ifollow_new = JsonObject_ifollow_new
								.getString("player2");
						String player3_ifollow_new = JsonObject_ifollow_new
								.getString("player3");
						String player4_ifollow_new = JsonObject_ifollow_new
								.getString("player4");

						String game_start_ifollow_new = JsonObject_ifollow_new
								.getString("ss_game_start");

						String team_sport_ifollow_new = JsonObject_ifollow_new
								.getString("ss_team_sport");

						String channel_code1_new = JsonObject_ifollow_new
								.getString("channel_name1");
						String channel_code2_new = JsonObject_ifollow_new
								.getString("channel_name2");
						String channel_code3_new = JsonObject_ifollow_new
								.getString("channel_name3");

						String ticket_url = JsonObject_ifollow_new
								.getString("ss_ticket_url");

						String match_code = JsonObject_ifollow_new
								.getString("ss_match_code");

						String player1_club5 = JsonObject_ifollow_new
								.getString("player1_club5");

						String player2_club5 = JsonObject_ifollow_new
								.getString("player2_club5");

						String player1_country = JsonObject_ifollow_new
								.getString("player1_country");

						String player2_country = JsonObject_ifollow_new
								.getString("player2_country");

						String player3_country = JsonObject_ifollow_new
								.getString("player3_country");

						String player4_country = JsonObject_ifollow_new
								.getString("player4_country");

						String match_text = JsonObject_ifollow_new
								.getString("ss_match_text");

						String game_text = JsonObject_ifollow_new
								.getString("ss_game_text");

						String sport_code = JsonObject_ifollow_new
								.getString("ss_sport_code");

						SimpleDateFormat formatter = new SimpleDateFormat(
								"yyyyMMddHHmmss");
						formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
						Date date = (Date) formatter
								.parse(game_start_ifollow_new);

						// Log.e("suraj", "DA==" + date);

						SimpleDateFormat dateFormat = new SimpleDateFormat(
								"dd-MMM hh:mm a");

						String mydate = null;

						dateFormat.setTimeZone(TimeZone.getDefault());

						SimpleDateFormat dayFormat = new SimpleDateFormat(
								"EEEE");
						String myday = dayFormat.format(date).toUpperCase();
						mydate = dateFormat.format(date);

						SimpleDateFormat dateFormat1 = new SimpleDateFormat(
								"dd-MM-yyyy hh:mm a");

						String mydate1 = null;

						dateFormat1.setTimeZone(TimeZone.getDefault());
						mydate1 = dateFormat1.format(date);

						SimpleDateFormat formatter1 = new SimpleDateFormat(
								"yyyyMMddHHmmss");
						formatter1.setTimeZone(TimeZone.getTimeZone("UTC"));
						Date date11 = (Date) formatter1
								.parse(JsonObject_ifollow_new
										.getString("ss_game_start"));

						SimpleDateFormat dateFormat11 = new SimpleDateFormat(
								"EEE dd MMM yyyy");

						String mydate_cs = null;

						dateFormat11.setTimeZone(TimeZone.getDefault());

						SimpleDateFormat timeFormat1 = new SimpleDateFormat(
								"hh:mm a");

						String mytime_cs = null;
						if (match_text == null || match_text.equals("")) {
							mytime_cs = timeFormat1.format(date11)
									.toUpperCase();
						} else {
							mytime_cs = match_text + ":  "
									+ timeFormat1.format(date11).toUpperCase();
						}

						mydate_cs = dateFormat11.format(date11);

						SimpleDateFormat formatter11 = new SimpleDateFormat(
								"yyyyMMddHHmmss");
						formatter11.setTimeZone(TimeZone.getTimeZone("UTC"));
						Date date111 = (Date) formatter11
								.parse(JsonObject_ifollow_new
										.getString("ss_game_start"));

						SimpleDateFormat dateFormat111 = new SimpleDateFormat(
								"EEE dd MMM yyyy");

						String mydate11 = null;

						dateFormat111.setTimeZone(TimeZone.getDefault());

						SimpleDateFormat timeFormat11 = new SimpleDateFormat(
								"HH:mm");
						String mytime = timeFormat11.format(date111)
								.toUpperCase();
						mydate11 = dateFormat111.format(date111);

						String follow_pl = null;
						if (i == 0) {
							prev_type = array_ifollow_new.getJSONObject(i)
									.getString("ss_team_sport");
						}
						if (i > 0) {
							prev_type = array_ifollow_new.getJSONObject(i - 1)
									.getString("ss_team_sport");
						}
						if (i == 0) {
							prev_game = array_ifollow_new.getJSONObject(i)
									.getString("ss_game_text");
						}
						if (i > 0) {
							prev_game = array_ifollow_new.getJSONObject(i - 1)
									.getString("ss_game_text");
						}

						if (i == 0) {

							Date data_pre = (Date) formatter11
									.parse(array_ifollow_new.getJSONObject(i)
											.getString("ss_game_start"));

							prev_date = dateFormat111.format(data_pre);
						}
						if (i > 0) {
							Date date_pre = (Date) formatter11
									.parse(array_ifollow_new.getJSONObject(
											i - 1).getString("ss_game_start"));
							prev_date = dateFormat111.format(date_pre);
						}

						if (pl_list1.contains(player_code1_new) == true)// ||||||)
						{
							follow_pl = player_code1_new;
						} else if (pl_list1.contains(player_code2_new) == true) {
							follow_pl = player_code2_new;
						} else if (pl_list1.contains(player_code3_new) == true) {
							follow_pl = player_code3_new;
						} else if (pl_list1.contains(player_code4_new) == true) {
							follow_pl = player_code4_new;
						}

						if (i == 0) {
							if (team_sport_ifollow_new.equals("Y")
									|| team_sport_ifollow_new.equals("N")) {
								i_follow_data1 = cs_code_new + ";"
										+ cs_name_new + ";" + sport_name_new
										+ ";" + sport_code + ";"
										+ team_sport_ifollow_new + ";"
										+ follow_pl + ";" + match_code
										+ ";match," + player_code1_new + ":"
										+ player1_ifollow_new + ":"
										+ player1_country + ":" + player1_club5
										+ ":" + player_code2_new + ":"
										+ player2_ifollow_new + ":"
										+ player2_country + ":" + player2_club5
										+ ":" + player_code3_new + ":"
										+ player3_ifollow_new + ":"
										+ player3_country + ":"
										+ player_code4_new + ":"
										+ player4_ifollow_new + ":"
										+ player4_country + ";" + myday + ","
										+ mydate + "," + mydate1 + ";"
										+ ticket_url + ";channels,"
										+ channel_code1_new + ":"
										+ channel_code2_new + ":"
										+ channel_code3_new + ";" + game_text
										+ " : " + match_text;
								count++;

							} else {
								i_follow_champ_data1 = cs_code_new
										+ ";"
										+ cs_name_new.toUpperCase()
										+ ";"
										+ sport_name_new
										+ ";"
										+ sport_code
										+ ";"
										+ ticket_url
										+ ","
										+ "match!"
										+ JsonObject_ifollow_new.getString(
												"ss_game_text").toUpperCase()
										+ "!channel," + channel_code1_new + ":"
										+ channel_code2_new + ":"
										+ channel_code3_new + "!" + mydate1
										+ "!" + "date," + mydate11 + "!"
										+ "time," + mytime_cs;
								chmp_count++;
							}
						}
						if (i > 0) { // This means it is not first record.

							// Log.d("suraj",
							// "ss_cs_code ="+JsonObject_ifollow_new.getString("ss_cs_code"));
							// Log.d("suraj", "prev_champ ="+prev_champ);
							// Log.d("suraj",
							// "team_sport_ifollow_new ="+team_sport_ifollow_new);

							if (team_sport_ifollow_new.equals("Y")
									|| team_sport_ifollow_new.equals("N")) {

								if (JsonObject_ifollow_new.getString(
										"ss_cs_code").equals(prev_champ)) {
									// This means no championship change from
									// previous record

									// Log.d("suraj", "Same Champ");

									i_follow_data1 = i_follow_data1 + ";"
											+ match_code + ";match,"
											+ player_code1_new + ":"
											+ player1_ifollow_new + ":"
											+ player1_country + ":"
											+ player1_club5 + ":"
											+ player_code2_new + ":"
											+ player2_ifollow_new + ":"
											+ player2_country + ":"
											+ player2_club5 + ":"
											+ player_code3_new + ":"
											+ player3_ifollow_new + ":"
											+ player3_country + ":"
											+ player_code4_new + ":"
											+ player4_ifollow_new + ":"
											+ player4_country + ";" + myday
											+ "," + mydate + "," + mydate1
											+ ";" + ticket_url + ";channels,"
											+ channel_code1_new + ":"
											+ channel_code2_new + ":"
											+ channel_code3_new + ";"
											+ game_text + " : " + match_text;
									count++;
								} else {
									new_upcoming_match
											.add(new new_ifollow_player(
													i_follow_data1, null,
													team_sport_ifollow_new,
													null, count));

									i_follow_data1 = cs_code_new + ";"
											+ cs_name_new + ";"
											+ sport_name_new + ";" + sport_code
											+ ";" + team_sport_ifollow_new
											+ ";" + follow_pl + ";"
											+ match_code + ";match,"
											+ player_code1_new + ":"
											+ player1_ifollow_new + ":"
											+ player1_country + ":"
											+ player1_club5 + ":"
											+ player_code2_new + ":"
											+ player2_ifollow_new + ":"
											+ player2_country + ":"
											+ player2_club5 + ":"
											+ player_code3_new + ":"
											+ player3_ifollow_new + ":"
											+ player3_country + ":"
											+ player_code4_new + ":"
											+ player4_ifollow_new + ":"
											+ player4_country + ";" + myday
											+ "," + mydate + "," + mydate1
											+ ";" + ticket_url + ";channels,"
											+ channel_code1_new + ":"
											+ channel_code2_new + ":"
											+ channel_code3_new + ";"
											+ game_text + " : " + match_text;

									count = 0;
									count++;
								}

							} else { // This means championship type is A

								if (i_follow_champ_data1 == null) {
									i_follow_champ_data1 = cs_code_new
											+ ";"
											+ cs_name_new.toUpperCase()
											+ ";"
											+ sport_name_new
											+ ";"
											+ sport_code
											+ ";"
											+ ticket_url
											+ ","
											+ "match!"
											+ JsonObject_ifollow_new.getString(
													"ss_game_text")
													.toUpperCase()
											+ "!channel," + channel_code1_new
											+ ":" + channel_code2_new + ":"
											+ channel_code3_new + "!" + mydate1
											+ "!" + "date," + mydate11 + "!"
											+ "time," + mytime_cs;
									chmp_count++;
								} else {
									if (JsonObject_ifollow_new.getString(
											"ss_cs_code").equals(prev_champ) == true) { // This
																						// means
																						// championship
																						// type
																						// is
																						// A
																						// and
																						// previous
																						// championship
																						// =
																						// this
																						// championship

										if (prev_game
												.toString()
												.equals(JsonObject_ifollow_new
														.getString("ss_game_text")) == true) {
											if (prev_date.equals(mydate11) == true) {

												i_follow_champ_data1 = i_follow_champ_data1
														+ "!"
														+ "time,"
														+ mytime_cs;

											} else {

												i_follow_champ_data1 = i_follow_champ_data1
														+ "!"
														+ "date,"
														+ mydate11
														+ "!"
														+ "time," + mytime_cs;

											}
										} else {

											// MainActivity.new_follow_match.add(new
											// new_ifollow_player(null,i_follow_champ_data,team_sport_ifollow_new,chmp_count));

											i_follow_champ_data1 = i_follow_champ_data1
													+ ";"
													+ ticket_url
													+ ","
													+ "match!"
													+ JsonObject_ifollow_new
															.getString(
																	"ss_game_text")
															.toUpperCase()
													+ "!channel,"
													+ channel_code1_new
													+ ":"
													+ channel_code2_new
													+ ":"
													+ channel_code3_new
													+ "!"
													+ mydate1
													+ "!"
													+ "date,"
													+ mydate11
													+ "!"
													+ "time,"
													+ mytime_cs;

											// chmp_count=0;
											chmp_count++;
										}
									} else {

										new_upcoming_match
												.add(new new_ifollow_player(
														null,
														i_follow_champ_data1,
														team_sport_ifollow_new,
														null, chmp_count));

										i_follow_champ_data1 = cs_code_new
												+ ";"
												+ cs_name_new.toUpperCase()
												+ ";"
												+ sport_name_new
												+ ";"
												+ sport_code
												+ ";"
												+ ticket_url
												+ ","
												+ "match!"
												+ JsonObject_ifollow_new
														.getString(
																"ss_game_text")
														.toUpperCase()
												+ "!channel,"
												+ channel_code1_new + ":"
												+ channel_code2_new + ":"
												+ channel_code3_new + "!"
												+ mydate1 + "!" + "date,"
												+ mydate11 + "!" + "time,"
												+ mytime_cs;

										chmp_count = 0;

										chmp_count++;
									}
								}

							}
						}
						if (i == json_len - 1) { // This is to write last
													// record.
							if (team_sport_ifollow_new.equals("Y")
									|| team_sport_ifollow_new.equals("N")) {
								new_upcoming_match.add(new new_ifollow_player(
										i_follow_data1, null,
										team_sport_ifollow_new, null, count));
							} else {
								new_upcoming_match.add(new new_ifollow_player(
										null, i_follow_champ_data1,
										team_sport_ifollow_new, null,
										chmp_count));
							}

						}
					}

					Log.e("suraj", "Suraj msg=" + new_upcoming_match.size());

				} catch (Exception e) {
					e.printStackTrace();
				}

				return abc;
			}
		};
		wait.execute();

	}

	public void menu_sport_cs() {

		// findViewById(R.id.new_main_real_heading).setVisibility(
		// View.GONE);
		findViewById(R.id.new_web_btn_head).setVisibility(View.GONE);
		findViewById(R.id.new_hori_btn_head).setVisibility(View.GONE);
		findViewById(R.id.new_video_bar).setVisibility(View.GONE);

		LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
				.getSystemService(LAYOUT_INFLATER_SERVICE);
		View popupView = layoutInflater.inflate(R.layout.sub_option_popup_main,
				null);
		popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT, true);

		popupWindow.setOutsideTouchable(true);

		popupWindow.setOutsideTouchable(true);
		//
		LinearLayout rr = (LinearLayout) popupView.findViewById(R.id.sub_op_li);
		rr.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View arg0, MotionEvent arg1) {

				popupWindow.dismiss();

				return false;
			}
		});

		ImageView title_image = (ImageView) popupView
				.findViewById(R.id.image_menu);
		final ListView listView = (ListView) popupView
				.findViewById(R.id.sub_listView1);

		title_image.setImageResource(R.drawable.sports);
		TextView sub_menu_title = (TextView) popupView
				.findViewById(R.id.sub_menu_title);
		sub_menu_title.setText(br_sport_name);

		sub_menu_title.setTypeface(sport_font);

		final String Sport_name_detail = br_sport_name;

		int bl = Color.parseColor("#000000"); // The color u want
		title_image.setColorFilter(bl);

		all_sport.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.tab_button));
		all_sport.setCompoundDrawablesWithIntrinsicBounds(0, 0,
				R.drawable.arrow_yellow, 0);
		all_sport.setTextColor(Color.parseColor("#FFCC11"));

		cs_code = new HashMap<String, String>();

		final List<String> data_sub1 = new ArrayList<String>();
		final List<String> data_first = new ArrayList<String>();
		// listView.setAdapter(new ArrayAdapter<String>(getApplicationContext(),
		// android.R.layout.simple_list_item_1,data));
		final SubMenu menu_adapter = new SubMenu(getApplicationContext(),
				data_sub1);
		listView.setAdapter(menu_adapter);

		AsyncTask<Void, Void, List<String>> wait1 = new AsyncTask<Void, Void, List<String>>() {

			@Override
			protected void onPostExecute(List<String> result) {
				// TODO Auto-generated method stub
				super.onPostExecute(result);
				pd.dismiss();

				if (result.size() == 1) {
					popupWindow.dismiss();

					String[] cs = result.get(0).toString().split(":");

					cs_code_selected = cs[1];

					after_cs_select(cs[0]);
				} else {
					menu_adapter.notifyDataSetChanged();
				}

			}

			@Override
			protected void onPreExecute() {
				pd = ProgressDialog.show(context, "", "Loading...", true);
				super.onPreExecute();
			}

			@Override
			protected List<String> doInBackground(Void... params) {

				try {

					dataAdapter.open();
					sport_code = dataAdapter.getsportcodelist(br_sport_name);
					team_sports = dataAdapter.getsportteamlist(br_sport_name);
					dataAdapter.close();

					// code = sport_cde.split(":");

					final String jsonResult = Utils.readJsonFeed(
							"http://sportizza.com/interface/ios_get_cs.php?sport_code="
									+ sport_code + "", MainActivity.this);

					// Log.v("suraj_","jsonResult = "+jsonResult);

					if (jsonResult.equals("null") || jsonResult == null) {
						Toast.makeText(MainActivity.this,
								"Data Not Available check back later",
								Toast.LENGTH_SHORT).show();
						popupWindow.dismiss();
					} else {
						// empty.setVisibility(View.GONE);
						JSONArray array_sport = new JSONArray(jsonResult);

						int array_len = array_sport.length();

						// sport_cs_adp = new String[array_len];

						for (int i = 0; i < array_len; i++) {

							JSONObject JsonObject_sport = array_sport
									.getJSONObject(i);

							data_sub1
									.add(JsonObject_sport
											.getString("ss_cs_name")
											+ ":"
											+ sport_code);

							data_first.add(JsonObject_sport
									.getString("ss_cs_name")
									+ ":"
									+ JsonObject_sport.getString("ss_cs_code"));

							cs_code.put(
									JsonObject_sport.getString("ss_cs_name"),
									JsonObject_sport.getString("ss_cs_code"));
						}
					}
					// Log.v("suraj_","data_sub = "+data_sub);
				} catch (Exception e) {

					e.printStackTrace();
				}

				return data_first;
			}
		};
		wait1.execute();

		listView.setOnItemClickListener(new OnItemClickListener() {

			@SuppressWarnings("deprecation")
			@Override
			public void onItemClick(AdapterView<?> parent, View v,
					int position, long id) {

				popupWindow.dismiss();

				final TextView t = (TextView) v.findViewById(R.id.Menu_name);

				// Log.i("suraj_","listView.getItemAtPosition(position).toString() = "+t.getText().toString());

				cs_code_selected = cs_code.get(t.getText().toString());
				lv.setAdapter(null);
				after_cs_select(t.getText().toString().toUpperCase());

			}

		});

		popupWindow.showAsDropDown(option_popup, 0, 5);
	}

	protected void after_cs_select(final String cs_string) {

		new Thread(new Runnable() {
			public void run() {

				runOnUiThread(new Runnable() {
					public void run() {

						Log.i("suraj_", "cs_code_selected = "
								+ cs_code_selected);

						findViewById(R.id.new_main_real_heading).setVisibility(
								View.VISIBLE);

						final TextView main_champ_ = (TextView) findViewById(R.id.main_champ_name);
						final TextView main_sport_ = (TextView) findViewById(R.id.main_sport_name);

						main_champ_.setText(" " + cs_string);
						main_champ_.setTypeface(sport_font);

						Bitmap bi_result = null;

						try {
							bi_result = BitmapFactory.decodeStream(context
									.getResources()
									.getAssets()
									.open("sport_small/" + sport_code
											+ "_S.png"));
						} catch (IOException e1) {
							e1.printStackTrace();
							try {
								bi_result = BitmapFactory.decodeStream(context
										.getResources().getAssets()
										.open("sport_small/GAM_S.png"));
							} catch (IOException e) {
							}
						}

						if (bi_result == null) {
							main_champ_
									.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.team_selected, 0, 0, 0);

							main_champ_
									.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
						} else {
							Bitmap bitmap = Bitmap.createScaledBitmap(
									bi_result, 30, 30, true);

							Drawable tmpDraw = (Drawable) new BitmapDrawable(
									context.getResources(), bitmap);

							main_champ_
									.setCompoundDrawablesWithIntrinsicBounds(
											tmpDraw, null, null, null);
						}

						findViewById(R.id.new_main_real_heading).setVisibility(
								View.VISIBLE);
						findViewById(R.id.new_web_btn_head).setVisibility(
								View.GONE);
						findViewById(R.id.new_hori_btn_head).setVisibility(
								View.GONE);
						findViewById(R.id.new_video_bar).setVisibility(
								View.GONE);

						upcoming.setBackgroundDrawable(getResources()
								.getDrawable(R.drawable.tab_button));
						upcoming.setCompoundDrawablesWithIntrinsicBounds(0, 0,
								R.drawable.arrow_yellow, 0);
						upcoming.setTextColor(Color.parseColor("#FFCC11"));

						i_follow.setBackgroundDrawable(getResources()
								.getDrawable(R.drawable.tab_button));
						i_follow.setCompoundDrawablesWithIntrinsicBounds(0, 0,
								R.drawable.arrow_yellow, 0);
						i_follow.setTextColor(Color.parseColor("#FFCC11"));

						// all_sport.setBackgroundDrawable(getResources().getDrawable(
						// R.drawable.tab_button1));
						// all_sport.setCompoundDrawablesWithIntrinsicBounds(0,
						// 0, R.drawable.arrow_black_r, 0);
						// all_sport.setTextColor(Color.BLACK);

						main_sport_.setText(br_sport_name);
						main_sport_.setTypeface(sport_font);

						lv.setAdapter(null);

						if (team_sports.equals("Y")) {
							empty.setVisibility(View.GONE);

							webView1.setVisibility(View.INVISIBLE);

							btn_up.setTextColor(Color.parseColor("#FFCC11"));
							btn_up.setBackgroundColor(Color.BLACK);
							btn_up.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.addcalendar_yellow, 0, 0, 0);

							btn_teams.setTextColor(Color.parseColor("#000000"));
							btn_teams.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							btn_teams.setText("TEAMS");
							btn_teams.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.team_selected, 0, 0, 0);

							btn_news.setTextColor(Color.parseColor("#000000"));
							btn_news.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							btn_news.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.news_selected, 0, 0, 0);

							btn_tweets.setTextColor(Color.parseColor("#000000"));
							btn_tweets.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							btn_tweets.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.video, 0, 0, 0);

							// ====

							// final boolean up_y_team=true;

							pd = ProgressDialog.show(context, "", "Loading...",
									true);

							Thread thread1 = new Thread(new Runnable() {
								public void run() {

									try {
										Thread.sleep(2000);
									} catch (InterruptedException e) {
										e.printStackTrace();
									}
									runOnUiThread(new Runnable() {
										public void run() {

											adView.setVisibility(View.VISIBLE);
											lv.setVisibility(View.VISIBLE);
											lv.setDividerHeight(1);
											lv.setEmptyView(null);

											// lv.setEmptyView(findViewById(R.id.progressBar1));

											// empty.setVisibility(View.INVISIBLE);

											final PlayerAdapter1 player_adp = new PlayerAdapter1(
													new PlayerData(
															MainActivity.this,
															null, country_code,
															null,
															cs_code_selected,
															null, null, null,
															null, null, null,
															null, false, false,
															false, tablet,
															null, null,
															team_sports, true)
															.getPlayers());

											Log.d("suraj_",
													"player_adp.getCount() _team = "
															+ MainActivity.playerAdaptersize);
											if (MainActivity.playerAdaptersize != 0
													&& MainActivity.playerAdaptersize > 0) {

												empty.setVisibility(View.GONE);

												Thread thread = new Thread(
														new Runnable() {
															public void run() {

																runOnUiThread(new Runnable() {
																	public void run() {

																		lv.setAdapter(player_adp);
																		player_adp
																				.notifyDataSetChanged();
																		lv.invalidate();

																	}
																});
															}
														});
												thread.start();

											} else {

												empty.setVisibility(View.VISIBLE);
												empty.setText("Data Not Available check back later");
												lv.setEmptyView(empty);

												final Custom_dialog_class custom_dialog = new Custom_dialog_class(
														MainActivity.this,
														"check_back", true,
														null, true);
												custom_dialog.show();

												final Timer t = new Timer();
												t.schedule(new TimerTask() {
													public void run() {
														custom_dialog.dismiss();
														t.cancel();
													}
												}, 2000);

											}

										}
									});
									pd.dismiss();
								}

							});
							thread1.start();

							// ====

							btn_up.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View arg0) {

									empty.setVisibility(View.GONE);
									lv.setAdapter(null);

									btn_up.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_up.setBackgroundColor(Color.BLACK);
									// btn_up.setText("TEAMS");
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_yellow, 0,
											0, 0);

									btn_teams.setTextColor(Color
											.parseColor("#000000"));
									btn_teams.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_selected,
													0, 0, 0);

									btn_news.setTextColor(Color
											.parseColor("#000000"));
									btn_news.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news_selected, 0, 0, 0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									// ====
									webView1.setVisibility(View.INVISIBLE);
									// final boolean up_y_team=true;

									pd = ProgressDialog.show(context, "",
											"Loading...", true);

									Thread thread1 = new Thread(new Runnable() {
										public void run() {

											try {
												Thread.sleep(3000);
											} catch (InterruptedException e) {
												e.printStackTrace();
											}
											runOnUiThread(new Runnable() {
												public void run() {

													lv.setVisibility(View.VISIBLE);
													lv.setDividerHeight(1);
													lv.setEmptyView(null);

													// lv.setEmptyView(findViewById(R.id.progressBar1));

													// empty.setVisibility(View.INVISIBLE);

													final PlayerAdapter1 player_adp = new PlayerAdapter1(
															new PlayerData(
																	MainActivity.this,
																	null,
																	country_code,
																	null,
																	cs_code_selected,
																	null,
																	null,
																	null,
																	null,
																	null,
																	null,
																	null,
																	false,
																	false,
																	false,
																	tablet,
																	null,
																	null,
																	team_sports,
																	true)
																	.getPlayers());

													if (MainActivity.playerAdaptersize != 0
															&& MainActivity.playerAdaptersize > 0) {

														empty.setVisibility(View.GONE);

														Thread thread = new Thread(
																new Runnable() {
																	public void run() {

																		runOnUiThread(new Runnable() {
																			public void run() {

																				lv.setAdapter(player_adp);
																				player_adp
																						.notifyDataSetChanged();
																				lv.invalidate();

																				// img_relative
																				// .setVisibility(View.GONE);

																			}
																		});
																	}
																});
														thread.start();

													} else {

														empty.setVisibility(View.VISIBLE);
														empty.setText("Data Not Available check back later");
														lv.setEmptyView(empty);

														final Custom_dialog_class custom_dialog = new Custom_dialog_class(
																MainActivity.this,
																"check_back",
																true, null,
																true);
														custom_dialog.show();

														final Timer t = new Timer();
														t.schedule(
																new TimerTask() {
																	public void run() {
																		custom_dialog
																				.dismiss();
																		t.cancel();
																	}
																}, 2000);

													}

												}
											});
											pd.dismiss();
										}

									});
									thread1.start();

								}
							});

							btn_news.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View arg0) {

									empty.setVisibility(View.GONE);

									btn_up.setTextColor(Color
											.parseColor("#000000"));
									btn_up.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_black, 0, 0,
											0);

									btn_teams.setTextColor(Color
											.parseColor("#000000"));
									btn_teams.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_selected,
													0, 0, 0);

									btn_news.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_news.setBackgroundColor(Color.BLACK);
									// btn_up.setText("TEAMS");
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news, 0, 0, 0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									pd = ProgressDialog.show(context, "",
											"Loading...", true);

									Thread t = new Thread(new Runnable() {
										public void run() {

											try {
												Thread.sleep(4000);
											} catch (InterruptedException e) {
												e.printStackTrace();
											}
											runOnUiThread(new Runnable() {
												public void run() {

													// lv.setEmptyView(findViewById(R.id.progressBar1));

													lv.setVisibility(View.INVISIBLE);

													// String url_word =
													// champ_name_temp.replace(" ","+");

													String cs_name_url = main_champ_
															.getText()
															.toString()
															.replace(" ", "+")
															+ " "
															+ main_sport_
																	.getText()
																	.toString()
																	.replace(
																			" ",
																			"+");

													webView1.getSettings()
															.setJavaScriptEnabled(
																	true);
													webView1.getSettings()
															.setLoadWithOverviewMode(
																	true);
													webView1.getSettings()
															.setUseWideViewPort(
																	true);

													webView1.setWebViewClient(new WebViewClient() {

														@Override
														public void onPageFinished(
																WebView view,
																String url) {
															super.onPageFinished(
																	view, url);
															webView1.setVisibility(View.VISIBLE);
														}

														@Override
														public boolean shouldOverrideUrlLoading(
																WebView view,
																String url) {

															view.loadUrl(url);

															return true;
														}

													});

													Log.d("suraj",
															"url_word = "
																	+ cs_name_url);

													webView1.loadUrl("http://www.google.com/search?hl=en&gl="
															+ country_code
															+ "&tbm=nws&authuser=0&q="
															+ cs_name_url + "");
												}
											});
											pd.dismiss();
										}
									});

									t.start();

								}
							});

							btn_teams.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View v) {

									empty.setVisibility(View.GONE);

									btn_teams.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_teams.setBackgroundColor(Color.BLACK);
									btn_teams.setText("TEAMS");
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_ye, 0, 0, 0);

									btn_up.setTextColor(Color
											.parseColor("#000000"));
									btn_up.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_black, 0, 0,
											0);

									btn_news.setTextColor(Color
											.parseColor("#000000"));
									btn_news.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news_selected, 0, 0, 0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									webView1.setVisibility(View.INVISIBLE);

									final HashMap<String, String> team_code = new HashMap<String, String>();
									//
									sport_team_adp = new ArrayList<String>();

									final List<player_info> team_info = new ArrayList<player_info>();

									final new_Br_custom_team_list br_cTeamlist = new new_Br_custom_team_list(
											context, team_info);

									lv.setAdapter(br_cTeamlist);

									// Log.w("suraj","Team_code = "+lv.getItemAtPosition(position));

									AsyncTask<Void, Void, List<player_info>> wait = new AsyncTask<Void, Void, List<player_info>>() {

										@Override
										protected void onPostExecute(
												List<player_info> result) {
											// TODO Auto-generated method stub

											super.onPostExecute(result);
											if (result.size() > 0) {
												br_cTeamlist
														.notifyDataSetChanged();
											} else {
												Thread thread1 = new Thread(
														new Runnable() {
															public void run() {

																runOnUiThread(new Runnable() {
																	public void run() {
																		empty.setVisibility(View.VISIBLE);
																		empty.setText("Data Not Available check back later");
																		lv.setEmptyView(empty);
																	}
																});
															}
														});
												thread1.start();
											}
											pd.dismiss();
										}

										@Override
										protected void onPreExecute() {
											empty.setVisibility(View.GONE);
											pd = ProgressDialog.show(context,
													"", "Loading...", true);
											super.onPreExecute();
										}

										@Override
										protected List<player_info> doInBackground(
												Void... params) {

											final String teamlistjson = Utils
													.readJsonFeed(
															"http://sportizza.com/interface/ios_get_team_player.php?cs_code="
																	+ cs_code_selected
																	+ "",
															MainActivity.this);

											try {
												JSONArray array_team = new JSONArray(
														teamlistjson);

												int array_len = array_team
														.length();

												int count = 0;
												for (int i = 0; i < array_len; i++) {

													JSONObject JsonObject_sport = array_team
															.getJSONObject(i);

													String team_name = JsonObject_sport
															.getString("ss_player_name");
													String team_cd = JsonObject_sport
															.getString("ss_player_code");

													String ss_club5 = JsonObject_sport
															.getString("ss_club5");

													String ss_national_code = JsonObject_sport
															.getString("ss_national_code");

													Log.v("suraj",
															"team_name = "
																	+ sport_code
																	+ ":"
																	+ team_sports);

													team_info
															.add(new player_info(
																	team_name,
																	team_cd,
																	main_sport_
																			.getText()
																			.toString(),
																	sport_code,
																	ss_club5,
																	ss_national_code,
																	team_sports));

													if (team_name == null) {
													} else {
														sport_team_adp
																.add(team_name);
													}

													team_code.put(team_name,
															team_cd + ":"
																	+ ss_club5);
												}

											} catch (Exception e) {
											}

											Log.w("suraj", "team_code = "
													+ team_info.size());

											// lv.setAdapter(null);
											return team_info;
										}
									};
									wait.execute();
								}
							});
							btn_tweets
									.setOnClickListener(new OnClickListener() {

										@Override
										public void onClick(View v) {

											empty.setVisibility(View.GONE);

											btn_teams.setTextColor(Color
													.parseColor("#000000"));
											btn_teams.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_teams.setText("TEAMS");
											btn_teams
													.setCompoundDrawablesWithIntrinsicBounds(
															R.drawable.team_selected,
															0, 0, 0);

											btn_up.setTextColor(Color
													.parseColor("#000000"));
											btn_up.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_up.setText("TEAMS");
											btn_up.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.addcalendar_black,
													0, 0, 0);

											btn_news.setTextColor(Color
													.parseColor("#000000"));
											btn_news.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_up.setText("TEAMS");
											btn_news.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.news_selected,
													0, 0, 0);

											btn_tweets.setTextColor(Color
													.parseColor("#FFCC11"));
											btn_tweets
													.setBackgroundColor(Color.BLACK);
											// btn_up.setText("TEAMS");
											btn_tweets
													.setCompoundDrawablesWithIntrinsicBounds(
															R.drawable.video_yellow,
															0, 0, 0);

											webView1.setVisibility(View.INVISIBLE);

											final ArrayList<String> entity = new ArrayList<String>();
											final ArrayList<String> playlist = new ArrayList<String>();

											final Youtube_list youtube_adp = new Youtube_list(
													MainActivity.this, entity,
													playlist);
											lv.setAdapter(youtube_adp);

											AsyncTask<Void, Void, Integer> wait1 = new AsyncTask<Void, Void, Integer>() {

												@Override
												protected void onPostExecute(
														Integer result) {
													// TODO Auto-generated
													// method stub
													super.onPostExecute(result);
													pd.dismiss();
													if (result > 0) {
														youtube_adp
																.notifyDataSetChanged();
													} else {
														// lv.setAdapter(null);
														empty.setVisibility(View.VISIBLE);
														empty.setText("Video Not Available check back later");
														lv.setEmptyView(empty);
													}
												}

												@Override
												protected void onPreExecute() {
													pd = ProgressDialog.show(
															context, "",
															"Loading...", true);
													super.onPreExecute();
												}

												@Override
												protected Integer doInBackground(
														Void... params) {

													try {
														String _response = Utils
																.readJsonFeed(
																		"http://sportizza.com/interface/ios_youtube_api.php?player_code=-1&champ_code="
																				+ cs_code_selected
																				+ "&sport_code="
																				+ sport_code
																				+ "",
																		MainActivity.this);

														JSONArray array_entity = null;

														array_entity = new JSONArray(
																_response);

														int array_len1 = array_entity
																.length();

														for (int i = 0; i < array_len1; i++) {

															JSONObject jsonObject1 = array_entity
																	.getJSONObject(i);

															String ss_entity_code = jsonObject1
																	.getString("ss_entity_code");

															String entity_name = jsonObject1
																	.getString("entity_name");

															String ss_youtube_url = jsonObject1
																	.getString("ss_youtube_url");

															String play_list = ss_youtube_url
																	.substring(ss_youtube_url
																			.lastIndexOf("list=") + 1);

															if (!ss_entity_code
																	.equals("ALL")
																	&& !ss_entity_code
																			.equals("POP")) {
																if (ss_entity_code
																		.equals(cs_code_selected)
																		|| ss_entity_code
																				.equals(sport_code)) {
																	entity.add(entity_name);
																	playlist.add(play_list);
																}
															}
														}

														Log.i("suraj_",
																"playlist=="
																		+ playlist
																				.size());

													} catch (Exception e1) {
														e1.printStackTrace();
													}
													return playlist.size();
												}
											};
											wait1.execute();

											/*
											 * final HashMap<String, String>
											 * tweet_details = new
											 * HashMap<String, String>(); // //
											 * sport_team_adp=new
											 * ArrayList<String>();
											 * 
											 * final List<String> tweet_info =
											 * new ArrayList<String>();
											 * 
											 * final Br_custom_tweet_list
											 * br_tweetlist = new
											 * Br_custom_tweet_list( context,
											 * tweet_info, tweet_details);
											 * 
											 * lv.setAdapter(br_tweetlist);
											 * 
											 * AsyncTask<Void, Void, Void> wait
											 * = new AsyncTask<Void, Void,
											 * Void>() {
											 * 
											 * @Override protected void
											 * onPostExecute(Void result) { //
											 * TODO Auto-generated method stub
											 * super.onPostExecute(result);
											 * pd.dismiss();
											 * 
											 * br_tweetlist.notifyDataSetChanged(
											 * ); }
											 * 
											 * @Override protected void
											 * onPreExecute() { pd =
											 * ProgressDialog.show(context, "",
											 * "Loading...", true);
											 * super.onPreExecute(); }
											 * 
											 * @Override protected Void
											 * doInBackground(Void... params) {
											 * 
											 * String tweetlistjson =
											 * Utils.readJsonFeed(
											 * "http://sportizza.com/interface/ios_twitter_api.php?player_code=-1&champ_code="
											 * + cs_code_selected +
											 * "&sport_code=" + sport_code + "",
											 * MainActivity.this);
											 * 
											 * if (tweetlistjson == null ||
											 * tweetlistjson.equals("null")) {
											 * 
											 * Thread thread1 = new Thread( new
											 * Runnable() { public void run() {
											 * 
											 * try { } catch (Exception e) {
											 * e.printStackTrace(); }
											 * runOnUiThread(new Runnable() {
											 * public void run() {
											 * 
											 * empty.setVisibility(View.VISIBLE);
											 * empty.setText(
											 * "Data Not Available check back later"
											 * ); lv.setEmptyView(empty);
											 * 
											 * final Custom_dialog_class
											 * custom_dialog = new
											 * Custom_dialog_class(
											 * MainActivity.this, "check_back",
											 * true, null, true); custom_dialog
											 * .show();
											 * 
											 * final Timer t = new Timer();
											 * t.schedule( new TimerTask() {
											 * public void run() { custom_dialog
											 * .dismiss(); t.cancel(); } },
											 * 2000); } }); } });
											 * 
											 * thread1.start(); return null; }
											 * else {
											 * 
											 * //
											 * empty.setVisibility(View.GONE);
											 * 
											 * try { JSONArray array_tweet = new
											 * JSONArray( tweetlistjson);
											 * 
											 * int array_len = array_tweet
											 * .length();
											 * 
											 * int count = 0; for (int i = 0; i
											 * < array_len; i++) {
											 * 
											 * JSONObject JsonObject_sport =
											 * array_tweet .getJSONObject(i);
											 * 
											 * String ss_screen_name =
											 * JsonObject_sport
											 * .getString("ss_screen_name");
											 * 
											 * String ss_tw = JsonObject_sport
											 * .getString("ss_tw");
											 * 
											 * String ss_tweet_url =
											 * JsonObject_sport
											 * .getString("ss_tweet_url");
											 * 
											 * String ss_profile_url =
											 * JsonObject_sport
											 * .getString("ss_profile_url");
											 * 
											 * tweet_info.add(ss_screen_name +
											 * "''" + ss_tweet_url + "''" +
											 * ss_profile_url + "''" + ss_tw);
											 * 
											 * tweet_details .put(ss_tw,
											 * ss_screen_name + "''" +
											 * ss_tweet_url + "''" +
											 * ss_profile_url + "''" + ss_tw); }
											 * 
											 * } catch (Exception e) { }
											 * 
											 * Log.w("suraj_", "tweet_info = " +
											 * tweet_info);
											 * 
											 * // lv.setAdapter(null);
											 * 
											 * }
											 * 
											 * return null; }
											 * 
											 * };
											 * 
											 * wait.execute();
											 * 
											 * lv.setOnItemClickListener(new
											 * OnItemClickListener() {
											 * 
											 * @Override public void
											 * onItemClick(AdapterView<?>
											 * parent, View v, int position,
											 * long id) {
											 * 
											 * Log.d("suraj_", "Click On = " +
											 * tweet_info.get(position));
											 * 
											 * String[] url =
											 * tweet_info.get(position)
											 * .toString().split("''");
											 * 
											 * Log.d("suraj_", "url[1]==" +
											 * url[1]);
											 * 
											 * String urls = null; if (url[1] ==
											 * null || url[1].equals("")) { urls
											 * = url[3].substring(url[3]
											 * .lastIndexOf("http://")); //
											 * Log.d
											 * ("suraj_","URL11 = "+url[3].substring
											 * (url[3].lastIndexOf("http://")));
											 * } else { urls = url[1]; }
											 * 
											 * Log.d("suraj_", "URL = " + urls);
											 * 
											 * Uri uriUrl = Uri.parse(urls);
											 * Intent launchBrowser = new
											 * Intent( Intent.ACTION_VIEW,
											 * uriUrl);
											 * startActivity(launchBrowser); }
											 * });
											 */

										}
									});

						} else if (team_sports.equals("N")) {
							empty.setVisibility(View.GONE);

							webView1.setVisibility(View.INVISIBLE);

							btn_up.setTextColor(Color.parseColor("#FFCC11"));
							btn_up.setBackgroundColor(Color.BLACK);
							btn_up.setText("FIXTURES");
							btn_up.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.addcalendar_yellow, 0, 0, 0);

							btn_teams.setTextColor(Color.parseColor("#000000"));
							btn_teams.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							btn_teams.setText("PLAYERS");
							btn_teams.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.team_selected, 0, 0, 0);

							btn_news.setTextColor(Color.parseColor("#000000"));
							btn_news.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							// btn_up.setText("TEAMS");
							btn_news.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.news_selected, 0, 0, 0);

							btn_tweets.setTextColor(Color.parseColor("#000000"));
							btn_tweets.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							// btn_up.setText("TEAMS");
							btn_tweets.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.video, 0, 0, 0);

							// =====

							pd = ProgressDialog.show(context, "", "Loading...",
									true);

							Thread thread1 = new Thread(new Runnable() {
								public void run() {

									try {
										Thread.sleep(3000);
									} catch (InterruptedException e) {
										e.printStackTrace();
									}
									runOnUiThread(new Runnable() {
										public void run() {

											// search_text
											// .clearFocus();
											adView.setVisibility(View.VISIBLE);
											lv.setVisibility(View.VISIBLE);
											lv.setDividerHeight(1);
											lv.setEmptyView(null);

											// lv.setEmptyView(findViewById(R.id.progressBar1));

											// empty.setVisibility(View.INVISIBLE);

											final PlayerAdapter1 player_adp = new PlayerAdapter1(
													new PlayerData(
															MainActivity.this,
															null, country_code,
															null,
															cs_code_selected,
															null, null, null,
															null, null, null,
															null, false, false,
															false, tablet,
															null, null,
															team_sports, true)
															.getPlayers());

											if (MainActivity.playerAdaptersize != 0
													&& MainActivity.playerAdaptersize > 0) {

												// br_champ_name
												// .setText("UPCOMING MATCHES");
												empty.setVisibility(View.GONE);
												// SharedPreferences.Editor
												// editor_back4
												// = Back_action.edit();
												// editor_back4.putString("Back_action","after_select_champ_upcoming_matches");
												// editor_back4.commit();

												Thread thread = new Thread(
														new Runnable() {
															public void run() {

																runOnUiThread(new Runnable() {
																	public void run() {

																		lv.setAdapter(player_adp);
																		player_adp
																				.notifyDataSetChanged();
																		lv.invalidate();

																		// img_relative
																		// .setVisibility(View.GONE);

																	}
																});
															}
														});
												thread.start();

											} else {

												empty.setVisibility(View.VISIBLE);
												empty.setText("Data Not Available check back later");
												lv.setEmptyView(empty);

												final Custom_dialog_class custom_dialog = new Custom_dialog_class(
														MainActivity.this,
														"check_back", true,
														null, true);
												custom_dialog.show();

												final Timer t = new Timer();
												t.schedule(new TimerTask() {
													public void run() {
														custom_dialog.dismiss();
														t.cancel();
													}
												}, 2000);
											}

										}
									});
									pd.dismiss();
								}

							});
							thread1.start();

							// =====

							btn_up.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View v) {

									empty.setVisibility(View.GONE);

									lv.setAdapter(null);
									webView1.setVisibility(View.INVISIBLE);

									btn_up.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_up.setBackgroundColor(Color.BLACK);
									btn_up.setText("FIXTURES");
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_yellow, 0,
											0, 0);

									btn_teams.setTextColor(Color
											.parseColor("#000000"));
									btn_teams.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_teams.setText("PLAYERS");
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_selected,
													0, 0, 0);

									btn_news.setTextColor(Color
											.parseColor("#000000"));
									btn_news.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news_selected, 0, 0, 0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									// =====

									pd = ProgressDialog.show(context, "",
											"Loading...", true);

									Thread thread1 = new Thread(new Runnable() {
										public void run() {

											try {
												Thread.sleep(3000);
											} catch (InterruptedException e) {
												e.printStackTrace();
											}
											runOnUiThread(new Runnable() {
												public void run() {

													// search_text
													// .clearFocus();
													adView.setVisibility(View.VISIBLE);
													lv.setVisibility(View.VISIBLE);
													lv.setDividerHeight(1);
													lv.setEmptyView(null);

													// lv.setEmptyView(findViewById(R.id.progressBar1));

													// empty.setVisibility(View.INVISIBLE);

													final PlayerAdapter1 player_adp = new PlayerAdapter1(
															new PlayerData(
																	MainActivity.this,
																	null,
																	country_code,
																	null,
																	cs_code_selected,
																	null,
																	null,
																	null,
																	null,
																	null,
																	null,
																	null,
																	false,
																	false,
																	false,
																	tablet,
																	null,
																	null,
																	team_sports,
																	true)
																	.getPlayers());

													if (MainActivity.playerAdaptersize != 0
															&& MainActivity.playerAdaptersize > 0) {

														// br_champ_name
														// .setText("UPCOMING MATCHES");
														empty.setVisibility(View.GONE);
														// SharedPreferences.Editor
														// editor_back4
														// = Back_action.edit();
														// editor_back4.putString("Back_action","after_select_champ_upcoming_matches");
														// editor_back4.commit();

														Thread thread = new Thread(
																new Runnable() {
																	public void run() {

																		runOnUiThread(new Runnable() {
																			public void run() {

																				lv.setAdapter(player_adp);
																				player_adp
																						.notifyDataSetChanged();
																				lv.invalidate();

																				// img_relative
																				// .setVisibility(View.GONE);

																			}
																		});
																	}
																});
														thread.start();

													} else {

														empty.setVisibility(View.VISIBLE);
														empty.setText("Data Not Available check back later");
														lv.setEmptyView(empty);

														final Custom_dialog_class custom_dialog = new Custom_dialog_class(
																MainActivity.this,
																"check_back",
																true, null,
																true);
														custom_dialog.show();

														final Timer t = new Timer();
														t.schedule(
																new TimerTask() {
																	public void run() {
																		custom_dialog
																				.dismiss();
																		t.cancel();
																	}
																}, 2000);
													}

												}
											});
											pd.dismiss();
										}

									});
									thread1.start();

								}
							});

							btn_tweets
									.setOnClickListener(new OnClickListener() {

										@Override
										public void onClick(View v) {

											empty.setVisibility(View.GONE);

											btn_teams.setTextColor(Color
													.parseColor("#000000"));
											btn_teams.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_teams.setText("TEAMS");
											btn_teams
													.setCompoundDrawablesWithIntrinsicBounds(
															R.drawable.team_selected,
															0, 0, 0);

											btn_up.setTextColor(Color
													.parseColor("#000000"));
											btn_up.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_up.setText("TEAMS");
											btn_up.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.addcalendar_black,
													0, 0, 0);

											btn_news.setTextColor(Color
													.parseColor("#000000"));
											btn_news.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_up.setText("TEAMS");
											btn_news.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.news_selected,
													0, 0, 0);

											btn_tweets.setTextColor(Color
													.parseColor("#FFCC11"));
											btn_tweets
													.setBackgroundColor(Color.BLACK);
											// btn_up.setText("TEAMS");
											btn_tweets
													.setCompoundDrawablesWithIntrinsicBounds(
															R.drawable.video_yellow,
															0, 0, 0);

											webView1.setVisibility(View.INVISIBLE);

											final ArrayList<String> entity = new ArrayList<String>();
											final ArrayList<String> playlist = new ArrayList<String>();

											final Youtube_list youtube_adp = new Youtube_list(
													MainActivity.this, entity,
													playlist);
											lv.setAdapter(youtube_adp);

											AsyncTask<Void, Void, Integer> wait1 = new AsyncTask<Void, Void, Integer>() {

												@Override
												protected void onPostExecute(
														Integer result) {
													// TODO Auto-generated
													// method stub
													super.onPostExecute(result);
													pd.dismiss();
													if (result > 0) {
														youtube_adp
																.notifyDataSetChanged();
													} else {
														// lv.setAdapter(null);
														empty.setVisibility(View.VISIBLE);
														empty.setText("Video Not Available check back later");
														lv.setEmptyView(empty);
													}
												}

												@Override
												protected void onPreExecute() {
													pd = ProgressDialog.show(
															context, "",
															"Loading...", true);
													super.onPreExecute();
												}

												@Override
												protected Integer doInBackground(
														Void... params) {

													try {
														String _response = Utils
																.readJsonFeed(
																		"http://sportizza.com/interface/ios_youtube_api.php?player_code=-1&champ_code="
																				+ cs_code_selected
																				+ "&sport_code="
																				+ sport_code
																				+ "",
																		MainActivity.this);

														JSONArray array_entity = null;

														array_entity = new JSONArray(
																_response);

														int array_len1 = array_entity
																.length();

														for (int i = 0; i < array_len1; i++) {

															JSONObject jsonObject1 = array_entity
																	.getJSONObject(i);

															String ss_entity_code = jsonObject1
																	.getString("ss_entity_code");

															String entity_name = jsonObject1
																	.getString("entity_name");

															String ss_youtube_url = jsonObject1
																	.getString("ss_youtube_url");

															String play_list = ss_youtube_url
																	.substring(ss_youtube_url
																			.lastIndexOf("list=") + 1);

															if (!ss_entity_code
																	.equals("ALL")
																	&& !ss_entity_code
																			.equals("POP")) {
																if (ss_entity_code
																		.equals(cs_code_selected)
																		|| ss_entity_code
																				.equals(sport_code)) {
																	entity.add(entity_name);
																	playlist.add(play_list);
																}
															}
														}

														Log.i("suraj_",
																"playlist=="
																		+ playlist
																				.size());

													} catch (Exception e1) {
														e1.printStackTrace();
													}
													return playlist.size();
												}
											};
											wait1.execute();

											//
											// final HashMap<String, String>
											// tweet_details = new
											// HashMap<String, String>();
											// //
											// // sport_team_adp=new
											// ArrayList<String>();
											//
											// final List<String> tweet_info =
											// new ArrayList<String>();
											//
											// final Br_custom_tweet_list
											// br_tweetlist = new
											// Br_custom_tweet_list(
											// context, tweet_info,
											// tweet_details);
											//
											// lv.setAdapter(br_tweetlist);
											//
											// AsyncTask<Void, Void, Void> wait
											// = new AsyncTask<Void, Void,
											// Void>() {
											//
											// @Override
											// protected void onPostExecute(Void
											// result) {
											// // TODO Auto-generated method
											// stub
											// super.onPostExecute(result);
											// pd.dismiss();
											//
											// br_tweetlist.notifyDataSetChanged();
											// }
											//
											// @Override
											// protected void onPreExecute() {
											// pd = ProgressDialog.show(context,
											// "",
											// "Loading...", true);
											// super.onPreExecute();
											// }
											//
											// @Override
											// protected Void
											// doInBackground(Void... params) {
											//
											// String tweetlistjson =
											// Utils.readJsonFeed(
											// "http://sportizza.com/interface/ios_twitter_api.php?player_code=-1&champ_code="
											// + cs_code_selected
											// + "&sport_code="
											// + sport_code + "",
											// MainActivity.this);
											//
											// if (tweetlistjson == null
											// || tweetlistjson.equals("null"))
											// {
											//
											// Thread thread1 = new Thread(
											// new Runnable() {
											// public void run() {
											//
											// runOnUiThread(new Runnable() {
											// public void run() {
											//
											//
											// empty.setText("Data Not Available check back later");
											// lv.setEmptyView(empty);
											//
											// // final Custom_dialog_class
											// custom_dialog = new
											// Custom_dialog_class(
											// // MainActivity.this,
											// // "check_back",
											// // true,
											// // null,
											// // true);
											// // custom_dialog
											// // .show();
											// //
											// // final Timer t = new Timer();
											// // t.schedule(
											// // new TimerTask() {
											// // public void run() {
											// // custom_dialog
											// // .dismiss();
											// // t.cancel();
											// // }
											// // }, 2000);
											// empty.setVisibility(View.VISIBLE);
											// }
											// });
											// }
											// });
											//
											// thread1.start();
											// return null;
											// } else {
											// empty.setVisibility(View.GONE);
											//
											// try {
											// JSONArray array_tweet = new
											// JSONArray(
											// tweetlistjson);
											//
											// int array_len = array_tweet
											// .length();
											//
											// int count = 0;
											// for (int i = 0; i < array_len;
											// i++) {
											//
											// JSONObject JsonObject_sport =
											// array_tweet
											// .getJSONObject(i);
											//
											// String ss_screen_name =
											// JsonObject_sport
											// .getString("ss_screen_name");
											//
											// String ss_tw = JsonObject_sport
											// .getString("ss_tw");
											//
											// String ss_tweet_url =
											// JsonObject_sport
											// .getString("ss_tweet_url");
											//
											// String ss_profile_url =
											// JsonObject_sport
											// .getString("ss_profile_url");
											//
											// tweet_info.add(ss_screen_name
											// + "''" + ss_tweet_url
											// + "''" + ss_profile_url
											// + "''" + ss_tw);
											//
											// tweet_details
											// .put(ss_tw,
											// ss_screen_name
											// + "''"
											// + ss_tweet_url
											// + "''"
											// + ss_profile_url
											// + "''"
											// + ss_tw);
											// }
											//
											// } catch (Exception e) {
											// }
											//
											// Log.w("suraj_", "tweet_info = "
											// + tweet_info);
											//
											// // lv.setAdapter(null);
											//
											// }
											//
											// return null;
											// }
											//
											// };
											//
											// wait.execute();

										}
									});

							btn_news.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View arg0) {

									empty.setVisibility(View.GONE);

									btn_news.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_news.setBackgroundColor(Color.BLACK);
									// btn_up.setText("TEAMS");
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news, 0, 0, 0);

									btn_up.setTextColor(Color
											.parseColor("#000000"));
									btn_up.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_black, 0, 0,
											0);

									btn_teams.setTextColor(Color
											.parseColor("#000000"));
									btn_teams.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_selected,
													0, 0, 0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									pd = ProgressDialog.show(context, "",
											"Loading...", true);

									Thread t = new Thread(new Runnable() {
										public void run() {

											try {
												Thread.sleep(4000);
											} catch (InterruptedException e) {
												e.printStackTrace();
											}
											runOnUiThread(new Runnable() {
												public void run() {

													// lv.setEmptyView(findViewById(R.id.progressBar1));

													lv.setVisibility(View.INVISIBLE);

													// String url_word =
													// champ_name_temp.replace(" ","+");

													String cs_name_url = main_champ_
															.getText()
															.toString()
															.replace(" ", "+")
															+ " "
															+ main_sport_
																	.getText()
																	.toString()
																	.replace(
																			" ",
																			"+");

													webView1.getSettings()
															.setJavaScriptEnabled(
																	true);
													webView1.getSettings()
															.setLoadWithOverviewMode(
																	true);
													webView1.getSettings()
															.setUseWideViewPort(
																	true);

													webView1.setWebViewClient(new WebViewClient() {

														@Override
														public void onPageFinished(
																WebView view,
																String url) {
															super.onPageFinished(
																	view, url);
															webView1.setVisibility(View.VISIBLE);
														}

														@Override
														public boolean shouldOverrideUrlLoading(
																WebView view,
																String url) {

															view.loadUrl(url);

															return true;
														}

													});

													Log.d("suraj",
															"url_word = "
																	+ cs_name_url);

													webView1.loadUrl("http://www.google.com/search?hl=en&gl="
															+ country_code
															+ "&tbm=nws&authuser=0&q="
															+ cs_name_url + "");
												}
											});
											pd.dismiss();
										}
									});

									t.start();

								}
							});

							btn_teams.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View v) {

									empty.setVisibility(View.GONE);

									btn_teams.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_teams.setBackgroundColor(Color.BLACK);
									btn_teams.setText("PLAYERS");
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_ye, 0, 0, 0);

									btn_news.setTextColor(Color
											.parseColor("#000000"));
									btn_news.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news_selected, 0, 0, 0);

									btn_up.setTextColor(Color
											.parseColor("#000000"));
									btn_up.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_black, 0, 0,
											0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									webView1.setVisibility(View.INVISIBLE);

									final List<player_info> playerinfo = new ArrayList<player_info>();
									//
									sport_player_adp = new ArrayList<String>();

									webView1.setVisibility(View.GONE);

									final new_Br_custom_player_list br_player_list = new new_Br_custom_player_list(
											context, playerinfo);

									lv.setAdapter(br_player_list);

									AsyncTask<Void, Void, List<player_info>> wait = new AsyncTask<Void, Void, List<player_info>>() {

										@Override
										protected void onPostExecute(
												List<player_info> result) {
											// TODO Auto-generated method stub

											super.onPostExecute(result);
											if (result.size() > 0) {
												br_player_list
														.notifyDataSetChanged();
											} else {
												Thread thread1 = new Thread(
														new Runnable() {
															public void run() {

																runOnUiThread(new Runnable() {
																	public void run() {
																		empty.setVisibility(View.VISIBLE);
																		empty.setText("Data Not Available check back later");
																		lv.setEmptyView(empty);
																	}
																});
															}
														});
												thread1.start();
											}
											pd.dismiss();
										}

										@Override
										protected void onPreExecute() {
											empty.setVisibility(View.GONE);
											pd = ProgressDialog.show(context,
													"", "Loading...", true);
											super.onPreExecute();
										}

										@Override
										protected List<player_info> doInBackground(
												Void... params) {

											final String teamlistjson = Utils
													.readJsonFeed(
															"http://sportizza.com/interface/ios_get_team_player.php?cs_code="
																	+ cs_code_selected
																	+ "",
															MainActivity.this);

											try {
												JSONArray array_team = new JSONArray(
														teamlistjson);

												int array_len = array_team
														.length();

												int count = 0;
												for (int i = 0; i < array_len; i++) {

													JSONObject JsonObject_sport = array_team
															.getJSONObject(i);

													String team_name = JsonObject_sport
															.getString("ss_player_name");
													String team_cd = JsonObject_sport
															.getString("ss_player_code");

													String ss_club5 = JsonObject_sport
															.getString("ss_club5");

													String ss_national_code = JsonObject_sport
															.getString("ss_national_code");

													Log.v("suraj",
															"team_name = "
																	+ sport_code
																	+ ":"
																	+ team_sports);

													playerinfo
															.add(new player_info(
																	team_name,
																	team_cd,
																	main_sport_
																			.getText()
																			.toString(),
																	sport_code,
																	ss_club5,
																	ss_national_code,
																	team_sports));

												}

											} catch (Exception e) {
											}

											Log.w("suraj", "team_code = "
													+ playerinfo.size());

											// lv.setAdapter(null);
											return playerinfo;
										}
									};
									wait.execute();

								}
							});
							//
						} else if (team_sports.equals("A")) {

							// StartActivity.champ_game_txt

							empty.setVisibility(View.GONE);

							webView1.setVisibility(View.INVISIBLE);

							btn_up.setTextColor(Color.parseColor("#FFCC11"));
							btn_up.setBackgroundColor(Color.BLACK);
							btn_up.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.addcalendar_yellow, 0, 0, 0);

							btn_teams.setTextColor(Color.parseColor("#000000"));
							btn_teams.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							btn_teams.setText("TEAMS");
							btn_teams.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.team_selected, 0, 0, 0);

							btn_news.setTextColor(Color.parseColor("#000000"));
							btn_news.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							// btn_up.setText("TEAMS");
							btn_news.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.news_selected, 0, 0, 0);

							btn_tweets.setTextColor(Color.parseColor("#000000"));
							btn_tweets.setBackgroundColor(Color
									.parseColor("#FFCC11"));
							// btn_up.setText("TEAMS");
							btn_tweets.setCompoundDrawablesWithIntrinsicBounds(
									R.drawable.video, 0, 0, 0);

							pd = ProgressDialog.show(context, "", "Loading...",
									true);

							Thread thread1 = new Thread(new Runnable() {
								public void run() {

									try {
										Thread.sleep(3000);
									} catch (InterruptedException e) {
										e.printStackTrace();
									}
									runOnUiThread(new Runnable() {
										public void run() {

											// search_text
											// .clearFocus();
											adView.setVisibility(View.VISIBLE);
											lv.setVisibility(View.VISIBLE);
											lv.setDividerHeight(1);
											lv.setEmptyView(null);

											// lv.setEmptyView(findViewById(R.id.progressBar1));

											// empty.setVisibility(View.INVISIBLE);

											final PlayerAdapter1 player_adp = new PlayerAdapter1(
													new PlayerData(
															MainActivity.this,
															null, country_code,
															null,
															cs_code_selected,
															null, null, null,
															null, null, null,
															null, false, false,
															false, tablet,
															null, null,
															team_sports, true)
															.getPlayers());

											if (player_adp.getCount() != 0
													&& player_adp.getCount() > 0) {

												// br_champ_name
												// .setText("UPCOMING MATCHES");
												empty.setVisibility(View.GONE);
												// SharedPreferences.Editor
												// editor_back4
												// = Back_action.edit();
												// editor_back4.putString("Back_action","after_select_champ_upcoming_matches");
												// editor_back4.commit();

												Thread thread = new Thread(
														new Runnable() {
															public void run() {

																runOnUiThread(new Runnable() {
																	public void run() {

																		lv.setAdapter(player_adp);
																		player_adp
																				.notifyDataSetChanged();
																		lv.invalidate();

																		// img_relative
																		// .setVisibility(View.GONE);

																	}
																});
															}
														});
												thread.start();

											} else {

												empty.setVisibility(View.VISIBLE);
												empty.setText("Data Not Available check back later");
												lv.setEmptyView(empty);

												final Custom_dialog_class custom_dialog = new Custom_dialog_class(
														MainActivity.this,
														"check_back", true,
														null, true);
												custom_dialog.show();

												final Timer t = new Timer();
												t.schedule(new TimerTask() {
													public void run() {
														custom_dialog.dismiss();
														t.cancel();
													}
												}, 2000);
											}

										}
									});
									pd.dismiss();
								}

							});
							thread1.start();

							// =====

							btn_tweets
									.setOnClickListener(new OnClickListener() {

										@Override
										public void onClick(View v) {
											empty.setVisibility(View.GONE);
											btn_teams.setTextColor(Color
													.parseColor("#000000"));
											btn_teams.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_teams.setText("TEAMS");
											btn_teams
													.setCompoundDrawablesWithIntrinsicBounds(
															R.drawable.team_selected,
															0, 0, 0);

											btn_up.setTextColor(Color
													.parseColor("#000000"));
											btn_up.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_up.setText("TEAMS");
											btn_up.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.addcalendar_black,
													0, 0, 0);

											btn_news.setTextColor(Color
													.parseColor("#000000"));
											btn_news.setBackgroundColor(Color
													.parseColor("#FFCC11"));
											// btn_up.setText("TEAMS");
											btn_news.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.news_selected,
													0, 0, 0);

											btn_tweets.setTextColor(Color
													.parseColor("#FFCC11"));
											btn_tweets
													.setBackgroundColor(Color.BLACK);
											// btn_up.setText("TEAMS");
											btn_tweets
													.setCompoundDrawablesWithIntrinsicBounds(
															R.drawable.video_yellow,
															0, 0, 0);

											webView1.setVisibility(View.INVISIBLE);

											final ArrayList<String> entity = new ArrayList<String>();
											final ArrayList<String> playlist = new ArrayList<String>();

											final Youtube_list youtube_adp = new Youtube_list(
													MainActivity.this, entity,
													playlist);
											lv.setAdapter(youtube_adp);

											AsyncTask<Void, Void, Integer> wait1 = new AsyncTask<Void, Void, Integer>() {

												@Override
												protected void onPostExecute(
														Integer result) {
													// TODO Auto-generated
													// method stub
													super.onPostExecute(result);
													pd.dismiss();
													if (result > 0) {
														youtube_adp
																.notifyDataSetChanged();
													} else {
														// lv.setAdapter(null);
														empty.setVisibility(View.VISIBLE);
														empty.setText("Video Not Available check back later");
														lv.setEmptyView(empty);
													}
												}

												@Override
												protected void onPreExecute() {
													pd = ProgressDialog.show(
															context, "",
															"Loading...", true);
													super.onPreExecute();
												}

												@Override
												protected Integer doInBackground(
														Void... params) {

													try {
														String _response = Utils
																.readJsonFeed(
																		"http://sportizza.com/interface/ios_youtube_api.php?player_code=-1&champ_code="
																				+ cs_code_selected
																				+ "&sport_code="
																				+ sport_code
																				+ "",
																		MainActivity.this);

														Log.d("suraj",
																"CHAMP _ VIDEO = http://sportizza.com/interface/ios_youtube_api.php?player_code=-1&champ_code="
																		+ cs_code_selected
																		+ "&sport_code="
																		+ sport_code
																		+ "");

														JSONArray array_entity = null;

														array_entity = new JSONArray(
																_response);

														int array_len1 = array_entity
																.length();

														for (int i = 0; i < array_len1; i++) {

															JSONObject jsonObject1 = array_entity
																	.getJSONObject(i);

															String ss_entity_code = jsonObject1
																	.getString("ss_entity_code");

															String entity_name = jsonObject1
																	.getString("entity_name");

															String ss_youtube_url = jsonObject1
																	.getString("ss_youtube_url");

															String play_list = ss_youtube_url
																	.substring(ss_youtube_url
																			.lastIndexOf("list=") + 1);

															if (!ss_entity_code
																	.equals("ALL")
																	&& !ss_entity_code
																			.equals("POP")) {
																if (ss_entity_code
																		.equals(cs_code_selected)
																		|| ss_entity_code
																				.equals(sport_code)) {
																	entity.add(entity_name);
																	playlist.add(play_list);
																}
															}
														}

														Log.i("suraj_",
																"playlist=="
																		+ playlist
																				.size());

													} catch (Exception e1) {
														e1.printStackTrace();
													}
													return playlist.size();
												}
											};
											wait1.execute();

											// final HashMap<String, String>
											// tweet_details = new
											// HashMap<String, String>();
											// //
											// // sport_team_adp=new
											// ArrayList<String>();
											//
											// final List<String> tweet_info =
											// new ArrayList<String>();
											//
											// final Br_custom_tweet_list
											// br_tweetlist = new
											// Br_custom_tweet_list(
											// context, tweet_info,
											// tweet_details);
											//
											// lv.setAdapter(br_tweetlist);
											//
											// AsyncTask<Void, Void, Void> wait
											// = new AsyncTask<Void, Void,
											// Void>() {
											//
											// @Override
											// protected void onPostExecute(Void
											// result) {
											// // TODO Auto-generated method
											// stub
											// super.onPostExecute(result);
											// pd.dismiss();
											//
											// br_tweetlist.notifyDataSetChanged();
											// }
											//
											// @Override
											// protected void onPreExecute() {
											// pd = ProgressDialog.show(context,
											// "",
											// "Loading...", true);
											// super.onPreExecute();
											// }
											//
											// @Override
											// protected Void
											// doInBackground(Void... params) {
											//
											// String tweetlistjson =
											// Utils.readJsonFeed(
											// "http://sportizza.com/interface/ios_twitter_api.php?player_code=-1&champ_code="
											// + cs_code_selected
											// + "&sport_code="
											// + sport_code + "",
											// MainActivity.this);
											//
											// if (tweetlistjson == null
											// || tweetlistjson.equals("null"))
											// {
											//
											// Thread thread1 = new Thread(
											// new Runnable() {
											// public void run() {
											//
											// try {
											// } catch (Exception e) {
											// e.printStackTrace();
											// }
											// runOnUiThread(new Runnable() {
											// public void run() {
											// empty.setVisibility(View.VISIBLE);
											// empty.setText("Data Not Available check back later");
											// lv.setEmptyView(empty);
											//
											// final Custom_dialog_class
											// custom_dialog = new
											// Custom_dialog_class(
											// MainActivity.this,
											// "check_back",
											// true,
											// null,
											// true);
											// custom_dialog
											// .show();
											//
											// final Timer t = new Timer();
											// t.schedule(
											// new TimerTask() {
											// public void run() {
											// custom_dialog
											// .dismiss();
											// t.cancel();
											// }
											// }, 2000);
											// }
											// });
											// }
											// });
											//
											// thread1.start();
											// return null;
											// } else {
											// empty.setVisibility(View.GONE);
											// try {
											// JSONArray array_tweet = new
											// JSONArray(
											// tweetlistjson);
											//
											// int array_len = array_tweet
											// .length();
											//
											// int count = 0;
											// for (int i = 0; i < array_len;
											// i++) {
											//
											// JSONObject JsonObject_sport =
											// array_tweet
											// .getJSONObject(i);
											//
											// String ss_screen_name =
											// JsonObject_sport
											// .getString("ss_screen_name");
											//
											// String ss_tw = JsonObject_sport
											// .getString("ss_tw");
											//
											// String ss_tweet_url =
											// JsonObject_sport
											// .getString("ss_tweet_url");
											//
											// String ss_profile_url =
											// JsonObject_sport
											// .getString("ss_profile_url");
											//
											// tweet_info.add(ss_screen_name
											// + "''" + ss_tweet_url
											// + "''" + ss_profile_url
											// + "''" + ss_tw);
											//
											// tweet_details
											// .put(ss_tw,
											// ss_screen_name
											// + "''"
											// + ss_tweet_url
											// + "''"
											// + ss_profile_url
											// + "''"
											// + ss_tw);
											// }
											//
											// } catch (Exception e) {
											// }
											//
											// Log.w("suraj_", "tweet_info = "
											// + tweet_info);
											//
											// // lv.setAdapter(null);
											//
											// }
											//
											// return null;
											// }
											//
											// };
											//
											// wait.execute();

										}
									});

							btn_news.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View arg0) {
									empty.setVisibility(View.GONE);

									btn_news.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_news.setBackgroundColor(Color.BLACK);
									// btn_up.setText("TEAMS");
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news, 0, 0, 0);

									btn_up.setTextColor(Color
											.parseColor("#000000"));
									btn_up.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_black, 0, 0,
											0);

									btn_teams.setTextColor(Color
											.parseColor("#000000"));
									btn_teams.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_selected,
													0, 0, 0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									// btn_up.setText("TEAMS");
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									pd = ProgressDialog.show(context, "",
											"Loading...", true);

									Thread t = new Thread(new Runnable() {
										public void run() {

											try {
												Thread.sleep(4000);
											} catch (InterruptedException e) {
												e.printStackTrace();
											}
											runOnUiThread(new Runnable() {
												public void run() {

													// lv.setEmptyView(findViewById(R.id.progressBar1));

													lv.setVisibility(View.INVISIBLE);

													// String url_word =
													// champ_name_temp.replace(" ","+");

													String cs_name_url = main_champ_
															.getText()
															.toString()
															.replace(" ", "+")
															+ " "
															+ main_sport_
																	.getText()
																	.toString()
																	.replace(
																			" ",
																			"+");

													webView1.getSettings()
															.setJavaScriptEnabled(
																	true);
													webView1.getSettings()
															.setLoadWithOverviewMode(
																	true);
													webView1.getSettings()
															.setUseWideViewPort(
																	true);

													webView1.setWebViewClient(new WebViewClient() {

														@Override
														public void onPageFinished(
																WebView view,
																String url) {
															super.onPageFinished(
																	view, url);
															webView1.setVisibility(View.VISIBLE);
														}

														@Override
														public boolean shouldOverrideUrlLoading(
																WebView view,
																String url) {

															view.loadUrl(url);

															return true;
														}

													});

													Log.d("suraj",
															"url_word = "
																	+ cs_name_url);

													webView1.loadUrl("http://www.google.com/search?hl=en&gl="
															+ country_code
															+ "&tbm=nws&authuser=0&q="
															+ cs_name_url + "");
												}
											});
											pd.dismiss();
										}
									});

									t.start();

								}
							});

							btn_up.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View v) {

									empty.setVisibility(View.GONE);
									btn_up.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_up.setBackgroundColor(Color.BLACK);
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_yellow, 0,
											0, 0);

									btn_news.setTextColor(Color
											.parseColor("#000000"));
									btn_news.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news_selected, 0, 0, 0);

									btn_teams.setTextColor(Color
											.parseColor("#000000"));
									btn_teams.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_selected,
													0, 0, 0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									webView1.setVisibility(View.GONE);

									pd = ProgressDialog.show(context, "",
											"Loading...", true);

									Thread thread1 = new Thread(new Runnable() {
										public void run() {

											try {
												Thread.sleep(3000);
											} catch (InterruptedException e) {
												e.printStackTrace();
											}
											runOnUiThread(new Runnable() {
												public void run() {

													// search_text
													// .clearFocus();

													lv.setVisibility(View.VISIBLE);
													lv.setDividerHeight(1);
													lv.setEmptyView(null);

													// lv.setEmptyView(findViewById(R.id.progressBar1));

													// empty.setVisibility(View.INVISIBLE);

													final PlayerAdapter1 player_adp = new PlayerAdapter1(
															new PlayerData(
																	MainActivity.this,
																	null,
																	country_code,
																	null,
																	cs_code_selected,
																	null,
																	null,
																	null,
																	null,
																	null,
																	null,
																	null,
																	false,
																	false,
																	false,
																	tablet,
																	null,
																	null,
																	team_sports,
																	true)
																	.getPlayers());

													if (MainActivity.playerAdaptersize != 0
															&& MainActivity.playerAdaptersize > 0) {

														empty.setVisibility(View.GONE);

														// br_champ_name
														// .setText("UPCOMING MATCHES");

														Thread thread = new Thread(
																new Runnable() {
																	public void run() {

																		runOnUiThread(new Runnable() {
																			public void run() {

																				lv.setAdapter(player_adp);
																				player_adp
																						.notifyDataSetChanged();
																				lv.invalidate();

																				// img_relative
																				// .setVisibility(View.GONE);

																			}
																		});
																	}
																});
														thread.start();

													} else {
														empty.setVisibility(View.VISIBLE);
														empty.setText("Data Not Available check back later");
														lv.setEmptyView(empty);

														final Custom_dialog_class custom_dialog = new Custom_dialog_class(
																MainActivity.this,
																"check_back",
																true, null,
																true);
														custom_dialog.show();

														final Timer t = new Timer();
														t.schedule(
																new TimerTask() {
																	public void run() {
																		custom_dialog
																				.dismiss();
																		t.cancel();
																	}
																}, 2000);

													}

												}
											});
											pd.dismiss();
										}

									});
									thread1.start();

								}
							});

							btn_teams.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View v) {

									empty.setVisibility(View.GONE);

									btn_teams.setTextColor(Color
											.parseColor("#FFCC11"));
									btn_teams.setBackgroundColor(Color.BLACK);
									btn_teams.setText("TEAMS");
									btn_teams
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_ye, 0, 0, 0);

									btn_up.setTextColor(Color
											.parseColor("#000000"));
									btn_up.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_up.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.addcalendar_black, 0, 0,
											0);

									btn_news.setTextColor(Color
											.parseColor("#000000"));
									btn_news.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_news.setCompoundDrawablesWithIntrinsicBounds(
											R.drawable.news_selected, 0, 0, 0);

									btn_tweets.setTextColor(Color
											.parseColor("#000000"));
									btn_tweets.setBackgroundColor(Color
											.parseColor("#FFCC11"));
									btn_tweets
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.video, 0, 0, 0);

									final List<String> cs_team_list = new ArrayList<String>();
									//

									webView1.setVisibility(View.INVISIBLE);

									final ArrayAdapter<String> cs_team_adapter = new ArrayAdapter<String>(
											MainActivity.this,
											android.R.layout.simple_list_item_1,
											cs_team_list);

									lv.setAdapter(cs_team_adapter);

									AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

										@Override
										protected void onPostExecute(Void result) {
											super.onPostExecute(result);

											cs_team_adapter
													.notifyDataSetChanged();

											pd.dismiss();

										}

										@Override
										protected void onPreExecute() {
											lv.setEmptyView(null);

											pd = ProgressDialog.show(context,
													"", "Loading...", true);
											super.onPreExecute();
										}

										@Override
										protected Void doInBackground(
												Void... params) {
											new Thread(new Runnable() {
												public void run() {

													runOnUiThread(new Runnable() {
														public void run() {
															lv.setDividerHeight(1);
														}
													});
												}
											}).start();

											try {
												String playerlistjson = Utils
														.readJsonFeed(
																"http://sportizza.com/interface/ios_get_team_player.php?cs_code="
																		+ cs_code_selected
																		+ "",
																MainActivity.this);

												Log.w("suraj",
														"playerlistjson = "
																+ playerlistjson);

												if (playerlistjson
														.equals("null")
														|| playerlistjson == null) {

													Thread thread1 = new Thread(
															new Runnable() {
																public void run() {

																	try {
																	} catch (Exception e) {
																		e.printStackTrace();
																	}
																	runOnUiThread(new Runnable() {
																		public void run() {
																			empty.setVisibility(View.VISIBLE);
																			empty.setText("Data Not Available check back later");
																			lv.setEmptyView(empty);
																			final Custom_dialog_class custom_dialog = new Custom_dialog_class(
																					MainActivity.this,
																					"check_back",
																					true,
																					null,
																					true);
																			custom_dialog
																					.show();

																			final Timer t = new Timer();
																			t.schedule(
																					new TimerTask() {
																						public void run() {
																							custom_dialog
																									.dismiss();
																							t.cancel();
																						}
																					},
																					2000);
																		}
																	});
																}
															});

													thread1.start();
													return null;
												} else {

													JSONArray array_team = new JSONArray(
															playerlistjson);

													int array_len = array_team
															.length();

													for (int i = 0; i < array_len; i++) {

														JSONObject JsonObject_sport = array_team
																.getJSONObject(i);

														String player_name = JsonObject_sport
																.getString("ss_player_name");
														String player_cd = JsonObject_sport
																.getString("ss_player_code");

														String ss_club5 = JsonObject_sport
																.getString("ss_club5");

														String ss_national_code = JsonObject_sport
																.getString("ss_national_code");

														cs_team_list
																.add(player_name);

													}

													Log.w("suraj",
															"Team_code = "
																	+ sport_player_adp);
												}

											} catch (Exception e) {
											}

											return null;
										}

									};
									wait.execute();

								}
							});

						}

					}
				});
			}
		}).start();
	}
}
